-
Notifications
You must be signed in to change notification settings - Fork 0
/
slider.html
166 lines (144 loc) · 3.71 KB
/
slider.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
* {
margin: 0px;
padding: 0px;
/* display: block; */
}
img {
width: 100%;
/* display: block; */
}
.height {
height: 10px;
}
/* Image-container design */
.image-container {
max-width: 100%;
position: relative;
margin: auto;
margin-top: 30px;
}
.next {
right: 0;
}
/* Next and previous icon design */
.previous,
.next {
cursor: pointer;
position: absolute;
top: 50%;
padding: 10px;
margin-top: -25px;
}
/* caption decorate */
.captionText {
color: #000000;
font-size: 14px;
position: absolute;
padding: 12px 12px;
bottom: 8px;
width: 100%;
text-align: center;
}
.fa {
font-size: 32px;
}
.fa:hover {
transform: rotate(360deg);
transition: 1s;
color: white;
}
.footerdot {
cursor: pointer;
height: 10px;
width: 10px;
margin: 0 2px;
background-color: #bbbbbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.5s ease;
}
.active,
.footerdot:hover {
background-color: black;
}
</style>
</head>
<body>
<!-- Image container of the image slider -->
<div class="image-container">
<a href="">
<div class="slide">
<div class="slideNumber"></div>
<img src="./images/01Slider.png">
</div>
</a>
<a href="">
<div class="slide">
<div class="slideNumber"></div>
<img src="./images/02Slider.png">
</div>
</a>
<a href="">
<div class="slide">
<div class="slideNumber"></div>
<img src="./images/03Slider.png">
</div>
</a>
<!-- Next and Previous icon to change images -->
<a class="previous" onclick="moveSlides(-1)">
<i class="fa fa-chevron-circle-left"></i>
</a>
<a class="next" onclick="moveSlides(1)">
<i class="fa fa-chevron-circle-right"></i>
</a>
</div>
<br>
<div style="text-align:center">
<span class="footerdot" onclick="activeSlide(1)">
</span>
<span class="footerdot" onclick="activeSlide(2)">
</span>
<span class="footerdot" onclick="activeSlide(3)">
</span>
</div>
</body>
</html>
<script>
var slideIndex = 1;
displaySlide(slideIndex);
function moveSlides(n) {
displaySlide(slideIndex += n);
}
function activeSlide(n) {
displaySlide(slideIndex = n);
}
/* Main function */
function displaySlide(n) {
var i;
var totalslides =
document.getElementsByClassName("slide");
var totaldots =
document.getElementsByClassName("footerdot");
if (n > totalslides.length) {
slideIndex = 1;
}
if (n < 1) {
slideIndex = totalslides.length;
}
for (i = 0; i < totalslides.length; i++) {
totalslides[i].style.display = "none";
}
for (i = 0; i < totaldots.length; i++) {
totaldots[i].className =
totaldots[i].className.replace(" active", "");
}
totalslides[slideIndex - 1].style.display = "block";
totaldots[slideIndex - 1].className += " active";
}
</script>