-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
88 lines (75 loc) · 1.74 KB
/
Copy pathindex.html
File metadata and controls
88 lines (75 loc) · 1.74 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Slideshow</title>
<style>
.container {
width: fit-content;
margin: 50px auto;
position: relative;
}
.slide {
height: 400px;
width: 600px;
object-fit: cover;
border-radius: 10px;
}
.ico-action {
height: 80px;
position: absolute;
top: 40%;
cursor: pointer;
transition: 0.5s;
}
.ico-prev {
left: 0;
}
.ico-prev:hover {
transform: scale(0.8) translateX(-10px);
}
.ico-next {
right: 0;
}
.ico-next:hover {
transform: scale(0.8) translateX(10px);
}
</style>
</head>
<body>
<div class="container">
<img src="img/peacock.jpg" class="slide" id="slide" />
<img src="img/pre.png" class="ico-action ico-prev" onclick="prev()" />
<img src="img/next.png" class="ico-action ico-next" onclick="next()" />
</div>
<script>
const images = [
"img/peacock.jpg",
"img/parrot.jpg",
"img/duck.jpg",
"img/kingfisher.jpg",
"img/pigeons.jpg",
"img/sparrow.jpg",
];
let index = 0;
const slide = document.getElementById("slide");
function next() {
if (index < images.length - 1) {
index++;
} else {
index = 0;
}
slide.src = images[index];
}
function prev() {
if (index > 0) {
index--;
} else {
index = images.length - 1;
}
slide.src = images[index];
}
</script>
</body>
</html>