-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotating-img-gallery.html
More file actions
137 lines (114 loc) · 3.49 KB
/
Rotating-img-gallery.html
File metadata and controls
137 lines (114 loc) · 3.49 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
137
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
margin: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
height: 100vh;
background: black;
overflow: hidden;
}
.image-container {
position: relative;
width: 200px;
height: 200px;
transform-style: preserve-3d;
transform: perspective(1000px) rotateY(0deg);
transition: transform 0.7s;
}
.image-container span {
position: absolute;
left: 0;
top: 0;
width: 100%;
transform: rotateY(calc(var(--i) * 45deg)) translateZ(400px);
}
.image-container span img {
position: absolute;
left: 0;
top: 0;
width: 100%;
}
.btn-container {
position: relative;
width: 80%;
}
.btn {
position: absolute;
bottom: -80px;
background: crimson;
color: white;
border: none;
border-radius: 5px;
padding: 10px 20px;
cursor: pointer;
}
#prev {
left: 20%;
}
#next {
right: 20%;
}
.btn:hover {
filter: brightness(1.5);
}
</style>
</head>
<body>
<div class="image-container">
<span style="--i: 1">
<img src="/images/green-gallary/glowing-particles.webp" alt="" />
</span>
<span style="--i: 2">
<img src="images/green-gallary/black-green-texture.jpg" alt="" />
</span>
<span style="--i: 3">
<img src="images/green-gallary/center-green-gif.gif" alt="" />
</span>
<span style="--i: 4">
<img src="images/green-gallary/drops-green.jpg" alt="" />
</span>
<span style="--i: 5">
<img src="images/green-gallary/energy-vortex.webp" alt="" />
</span>
<span style="--i: 6">
<img src="images/green-gallary/green-leaf.jpg" alt="" />
</span>
<span style="--i: 7">
<img src="images/green-gallary/3d-modern-background-with-futuristic-flowing-dots.jpg" alt="" />
</span>
<span style="--i: 8">
<img src="images/green-gallary/digital.jpg" alt="" />
</span>
</div>
<div class="btn-container">
<button class="btn" id="prev">Prev</button>
<button class="btn" id="next">Next</button>
</div>
<script>
const imageContainer = document.querySelector('.image-container');
const prevBtn = document.getElementById("prev")
const nextBtn = document.getElementById("next")
let x = 0;
prevBtn.addEventListener("click", () => {
x = x + 45;
rotate()
})
nextBtn.addEventListener("click", () => {
x = x - 45;
rotate()
})
function rotate() {
imageContainer.style.transform = `perspective(1000px) rotateY(${x}deg)`
}
</script>
</body>
</html>