-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
70 lines (65 loc) · 2.73 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
<!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">
<title>Calculator</title>
<link rel="shortcut icon" type="image/jpg" href="calculator.png"/>
<link href="https://fonts.googleapis.com/css2?family=Spartan:wght@700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css"></link>
<script src="script.js" defer></script>
</head>
<body>
<div class="calculator-container">
<div class="heading">Calculator</div>
<div class="display">
<div data-prev-op class="prev-op"></div>
<div data-curr-op class="curr-op"></div>
</div>
<div class="calculator">
<button data-num class="button">7</button>
<button data-num class="button">8</button>
<button data-num class="button">9</button>
<button data-del class="button special1">Del</button>
<button data-num class="button">4</button>
<button data-num class="button">5</button>
<button data-num class="button">6</button>
<button data-operation class="button">+</button>
<button data-num class="button">1</button>
<button data-num class="button">2</button>
<button data-num class="button">3</button>
<button data-operation class="button">-</button>
<button data-num class="button">.</button>
<button data-num class="button">0</button>
<button data-operation class="button">÷</button>
<button data-operation class="button">*</button>
<button data-reset class="button span-two special1" style="padding:15px 10px 10px;">RESET</button>
<button data-equals class="button span-two special2">=</button>
</div>
</div>
</body>
<script>
const btns=document.querySelectorAll('button');
btns.forEach(btn=>{
btn.addEventListener('click',(e)=>{
let buf=btn.style.boxShadow;
btn.style.boxShadow="none";
btn.style.transform = "translate(0%,4%)";
let boffsetx=e.clientX-e.target.offsetLeft;
let boffsety=e.clientY-e.target.offsetTop;
let ripples=document.createElement('span');
ripples.style.left=boffsetx+'px';
ripples.style.top=boffsety+'px';
btn.appendChild(ripples);
setTimeout(()=>{
ripples.remove()
},500);
setTimeout(()=>{
btn.style.transform = "translate(0%,0%)";
btn.style.boxShadow=buf;
},100);
})
})
</script>
</html>