-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
194 lines (187 loc) · 8.2 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="shortcut icon"
href="./assets/images/favicon.png"
type="image/png"
/>
<!-- meta description -->
<meta
name="description"
content="Simple Calculator using HTML, CSS, and JavaScript"
/>
<!-- meta keywords -->
<meta
name="keywords"
content="HTML, CSS, JavaScript, Tailwind CSS, Calculator"
/>
<!-- meta author -->
<meta name="author" content="Md Rejoyan Islam" />
<!-- meta image -->
<meta
property="og:image"
content="https://md-rejoyan-islam.github.io/simple-calculator-using-javascript/assets/images/favicon.png"
/>
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="3 days" />
<meta name="language" content="English" />
<!-- meta title -->
<meta property="og:title" content="Simple Calculator" />
<script src="https://cdn.tailwindcss.com"></script>
<title>Simple Calculator</title>
</head>
<body class="bg-[#f5f7ff]">
<main
class="min-h-screen grid items-center content-center mx-auto w-fit py-10 px-4"
>
<div
class="calculator w-[300px] sm:w-[350px] px-4 py-5 bg-white shadow-[rgba(99,99,99,0.1)_0px_2px_8px_0px] mx-auto rounded-2xl"
>
<!-- calculator display -->
<div class="display">
<input
type="text"
class="text-right text-2xl px-4 py-6 bg-[#d8ddf0] font-bold w-full flex items-center"
id="show"
value="0"
/>
</div>
<div class="content mt-3 px-2">
<!-- calculator button div -->
<div
class="gap-x-5 gap-y-3 my-3 grid grid-cols-4 justify-items-center w-full"
id="calculatorBtn"
>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(7)"
>
7
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(8)"
>
<span>8</span>
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(9)"
>
9
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#2388ff] grid place-content-center text-white rounded-full p-2 sm:w-16 sm:h-16 h-12 w-12 outline-none text-2xl sm:text-5xl hover:bg-[#2388e1]"
onclick="getValue('/')"
>
<span class="p-0 -mt-1 sm:-mt-2 font-bold sm:font-semibold">
÷
</span>
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(4)"
>
4
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(5)"
>
5
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(6)"
>
6
</button>
<button
class="bg-[#ffc804] grid place-content-center text-white rounded-full p-2 w-12 h-12 sm:w-16 sm:h-16 outline-none text-2xl sm:text-5xl hover:opacity-70 active:scale-90 transition-transform duration-100"
onclick="getValue('*')"
>
<span class="p-0 -mt-1 sm:-mt-2 font-bold sm:font-semibold"
>×
</span>
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(1)"
>
1
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(2)"
>
2
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(3)"
>
3
</button>
<button
class="bg-[#ff445a] grid place-content-center text-white rounded-full p-2 sm:w-16 sm:h-16 outline-none text-2xl sm:text-5xl w-12 h-12 hover:opacity-50 active:scale-90 transition-transform duration-100"
onclick="getValue('-')"
>
<span class="p-0 -mt-1 sm:-mt-2 font-bold sm:font-semibold">
−
</span>
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] rounded-full p-2 w-12 h-12 sm:w-16 sm:h-16 font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff] flex items-center justify-center"
onclick="getValue('.')"
>
<span class="text-4xl -mt-5">.</span>
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#d8ddf0] w-12 h-12 sm:w-16 sm:h-16 rounded-full font-bold text-gray-600 outline-none text-xl sm:text-3xl hover:bg-[#d8ddff]"
onclick="getValue(0)"
>
0
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#63de77] grid place-content-center text-white rounded-full p-2 sm:w-16 sm:h-16 w-12 h-12 outline-none text-2xl sm:text-5xl hover:opacity-70"
onclick="getValue('+')"
>
<span class="p-0 -mt-1 sm:-mt-2 font-bold sm:font-semibold">
+
</span>
</button>
<button
class="active:scale-90 transition-transform duration-100 bg-[#c67909] grid place-content-center text-white rounded-full p-2 w-12 h-12 sm:w-16 sm:h-16 outline-none text-2xl sm:text-5xl hover:opacity-70"
onclick="getResult()"
>
<span class="p-0 -mt-1 sm:-mt-2 font-bold sm:font-semibold">
=
</span>
</button>
</div>
<div class="grid grid-cols-2 gap-2">
<!-- reset button -->
<button
class="active:scale-90 transition-transform duration-100 bg-[#1f2b54] rounded-full p-2 h-12 outline-none text-xl text-white w-full hover:opacity-70"
onclick="resetValue()"
>
AC
</button>
<!-- delete button -->
<button
class="active:scale-90 transition-transform duration-100 bg-[#fe4a00] hover:bg-[#fe0000ec] rounded-full p-2 h-12 outline-none text-xl text-white"
onclick="deleteValue()"
>
DEL
</button>
</div>
</div>
</div>
</main>
<script src="./assets/js/app.js"></script>
</body>
</html>