-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounter.html
127 lines (108 loc) · 2.61 KB
/
counter.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>counter</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
overflow: hidden;
}
:root {
--bg: #000000;
--text: #ffffff;
--accent: #00ea86;
--accent-darker: #01301c;
--icon-stroke: 3px solid var(--accent);
}
body {
background: var(--bg);
color: var(--text);
font-family: heebo, sans-serif;
}
.flex {
display: flex;
justify-content: center;
align-items: center;
}
.counterContainer {
flex-direction: column;
color: white;
}
h1 {
padding: 3rem;
}
.btn_container {
flex-direction: column;
}
button {
background: var(--accent-darker);
color: var(--accent);
border: var(--icon-stroke);
transition: background-color 0.4s ease;
}
/* Button style when clicked */
button:active {
background: var(--accent);
/* Change the background color on click */
color: var(--accent-darker);
/* Change the text color on click */
}
#increment {
font-size: 7rem;
height: 15rem;
width: 15rem;
border-radius: 50%;
position: relative;
}
#decrement {
font-size: 3rem;
font-weight: 600;
height: 10rem;
width: 10rem;
border: 5px solid black;
border-radius: 50%;
position: absolute;
top: 17rem;
}
#Reset {
height: 40px;
width: 200px;
border-radius: 3px;
position: absolute;
top: 30rem;
}
</style>
</head>
<body>
<div class="counterContainer flex">
<h1 id="counterElem">0</h1>
<button id="increment">^</button>
<button id="decrement">v</button>
<button id="Reset">Reset</button>
</div>
</div>
<script>
let count = 0;
let countElem = document.getElementById("counterElem");
const incrementBtn = document.getElementById("increment");
const resetBtn = document.getElementById("Reset");
const decrementBtn = document.getElementById("decrement");
incrementBtn.addEventListener("click", () => {
count++;
countElem.innerHTML = count;
});
resetBtn.addEventListener("click", () => {
count = 0;
countElem.innerHTML = count;
});
decrementBtn.addEventListener("click", () => {
count--;
countElem.innerHTML = count;
});
</script>
</body>
</html>