-
Notifications
You must be signed in to change notification settings - Fork 903
/
Copy pathindex.html
110 lines (106 loc) · 2.99 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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="https://kit.fontawesome.com/954076198c.js" crossorigin="anonymous"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Counter</title>
<style>
body{
background-color: #F3F8FF;
font-family: fantasy;
}
.container{
margin-left: 50%;
transform:translate(-50%, 50%);
display: flex;
flex-direction: column;
align-items: center;
width: 80%;
}
h1{
display: block;
text-align: center;
}
.btn{
border: none;
cursor: pointer;
background-color: transparent;
}
.btn1{
border-radius:10px ;
font-size: 20px;
font-family: fantasy;
cursor: pointer;
color: white;
background-color: black;
padding: 12px;
letter-spacing: 2px;
}
.btn1:hover{
background-color: black;
transition: 0.5s;
}
.fas{
color: #000;
font-size: 40px;
border: none;
}
.fas:hover{
transition: 0.5s;
color: #333;
}
#value{
font-size: 80px;
}
.button-container{
display: flex;
flex-wrap: wrap;
margin-top: 5%;
flex-direction: row;
justify-content: space-around;
}
</style>
</head>
<body>
<main>
<div class="container">
<h1>Counter</h1><span id="value">0</span>
<div class="button-container">
<button class="btn decrease"><i class="fas fa-minus-square"></i></button>
<button class="btn1 btn reset">RESET</button>
<button class="btn increase"><i class="fas fa-plus-square"></i></button>
</div>
</div>
</main>
<script>
let count =0;
const value = document.querySelector('#value')
const btns = document.querySelectorAll('.btn')
let decrease = document.querySelector('.decrease');
let reset = document.querySelector('.reset')
let increase = document.querySelector('.increase')
decrease.addEventListener('click',function(){
count--;
value.textContent= count;
if (count<0) {
value.style.color="red"
}
})
reset.addEventListener('click',function(){
count = 0;
value.textContent= count;
if (count=== 0) {
value.style.color="black"
}
})
increase.addEventListener('click',function(){
count++;
value.textContent= count;
if (count>0) {
value.style.color= "green"
}
})
</script>
</body>
</html>