-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
150 lines (139 loc) · 4.33 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<div class="calculator">
<input type="text" placeholder="Enter Values" class="display" disabled>
<div class="keys">
<div class="soft">
<button value="1">1</button>
<button value="2">2</button>
<button value="3">3</button>
<button value="/" class="soft-operator">/</button>
</div>
<div class="soft">
<button value="4">4</button>
<button value="5">5</button>
<button value="6">6</button>
<button value="+" class="soft-operator">+</button>
</div>
<div class="soft">
<button value="7">7</button>
<button value="8">8</button>
<button value="9">9</button>
<button value="-" class="soft-operator">-</button>
</div>
<div class="soft">
<button value="C" class="soft-operator">C</button>
<button value="0">0</button>
<button value="=" class="soft-operator">=</button>
<button value="*" class="soft-operator">*</button>
</div>
</div>
</div>
<style>
* {padding: 0;margin: 0;}
body {
width: 100vw;
height: 100vh;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
background-color:gray ;
font-family: sans-serif;
}
/* calculator */
.calculator {
width: 300px;
padding-bottom: 15px;
border-radius: 7px;
background-color: rgb(8, 255, 152);
box-shadow:
-0px -0px 4px 0px #ffffff,
4px 4px 8px 0px #d1d9e6,
4px 4px 4px 0px #d1d9e6 inset,
-4px -4px 4px 0px #ffffff inset;
}
/* Style */
.display {
width: 100%;
height: 80px;
border: none;
box-sizing: border-box;
padding: 10px;
font-size: 2rem;
background-color: #fff;
color: #000;
text-align: right;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
box-shadow:
-0px -0px 4px 0px #ffffff,
4px 4px 4px 0px #d1d9e6,
4px 4px 4px 0px #d1d9e6 inset,
-4px -4px 4px 0px #ffffff inset;
}
/* soft */
.soft {
display: flex;
justify-content: space-between;
}
/* soft style end */
button {
width: 50px;
height: 50px;
border-radius: 20%;
border: none;
outline: none;
font-weight: bold;
font-size: 1.5rem;
background-color:#D980FA ;
color: black;
margin: 10px;
box-shadow:
-0px -0px 0px 0px rgb(0, 204, 255),
4px 0px 0px 0px rgb(0, 247, 255),
0px 0px px 0px rgb(5, 247, 255) inset,
-4px -4px 4px 0px rgb(2, 238, 255) inset;
}
button:hover {
cursor: pointer;
background: #02a2ff;
}
/* soft-operator */
.soft-operator {
background-color: #066aff;
color: #000;
font-weight: bold;
box-shadow:
-1px -1px 4px 0px #ffffff,
4px 4px 4px 0px #d1d9e6,
4px 4px 4px 0px #d1d9e6 inset,
-4px -4px 4px 0px #ffffff inset;
}
.soft-operator:hover {
background-color: #FFC312 ;
color: #000;
font-weight: bold;
box-shadow:
-0px -0px 4px 0px #ffffff,
4px 4px 8px 0px #d1d9e6,
4px 4px 4px 0px #d1d9e6 inset,
-4px -4px 4px 0px #ffffff inset;
}
</style>
<script>
const buttons = document.querySelectorAll('button');
const display = document.querySelector('.display');
buttons.forEach(function (button) {
button.addEventListener('click', calculate);
});
function calculate(event) {
const clickedButtonValue = event.target.value;
if (clickedButtonValue === '=') {
if (display.value !== '') {
display.value = eval(display.value);
}
} else if (clickedButtonValue === 'C') {
display.value = '';
} else {
display.value += clickedButtonValue;
}
} </script>