-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.html
More file actions
136 lines (125 loc) · 4.03 KB
/
Copy pathnext.html
File metadata and controls
136 lines (125 loc) · 4.03 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Navigation</title>
<style>
body {
height: 100svh;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.bar-container {
display: flex;
align-items: center;
justify-content: center;
}
.circle {
height: 20px;
width: 20px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
border: 2px solid gainsboro;
cursor: pointer;
transition: border 1s ease;
}
.bar {
border: 1px solid gainsboro;
height: 1px;
width: 70px;
cursor: pointer;
background-color: gainsboro;
transition: background-color 1s ease, border 1s ease;
}
.buttons {
margin-top: 30px;
display: flex;
align-items: center;
justify-content: space-around;
}
button {
cursor: pointer;
font-size: 1rem;
background-color: aqua;
border: none;
width: 100px;
height: 40px;
border-radius: 10px;
color: white;
}
button:hover {
color: black;
opacity: 0.85;
}
</style>
</head>
<body>
<div class="container">
<div class="bar-container">
<div class="circle">1</div>
<div class="bar"></div>
<div class="circle">2</div>
<div class="bar"></div>
<div class="circle">3</div>
<div class="bar"></div>
<div class="circle">4</div>
<div class="bar"></div>
<div class="circle">5</div>
</div>
<div class="buttons">
<button id="previous">Previous</button>
<button id="next">Next</button>
</div>
</div>
<script>
const bar = document.querySelectorAll(".bar");
const circle = document.querySelectorAll(".circle");
let circle_index = 0, border_index = 0, max = 5, min = 0;
const prev_btn = document.getElementById("previous");
const next_btn = document.getElementById("next");
toggle_btn(previous, "not-allowed", "gray");
toggle(circle[circle_index], "white", "2px solid aqua");
document.getElementById("previous").addEventListener("click", function () {
if (border_index >= min) {
toggle_btn(next_btn, "pointer", "aqua");
if (border_index != 0) {
toggle(circle[circle_index], "white", "2px solid gainsboro");
border_index--;
circle_index--;
}
if (border_index == 0) {
toggle_btn(prev_btn, "not-allowed", "gray");
}
toggle(bar[border_index], "gainsboro", "1px solid gainsboro");
}
});
document.getElementById("next").addEventListener("click", function () {
if (border_index < max - 1) {
toggle_btn(prev_btn, "pointer", "aqua");
circle_index++;
toggle(bar[border_index], "aqua", "1px solid aqua");
toggle(circle[circle_index], "white", "2px solid aqua");
if (border_index != 4) {
border_index++;
}
if (border_index == 4) {
toggle_btn(next_btn, "not-allowed", "gray");
}
}
});
function toggle(cr, bc, bor) {
cr.style.backgroundColor = bc;
cr.style.border = bor;
}
function toggle_btn(btn, ptr, col) {
btn.style.cursor = ptr;
btn.style.backgroundColor = col;
}
</script>
</body>
</html>