-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
166 lines (140 loc) · 5.18 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
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 lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scroll Gallery</title>
<style>
:root {
color-scheme: light dark;
}
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.container {
max-width: 100vw;
text-align: center;
timeline-scope: --carousel;
.slider {
display: flex;
width: calc(100vw - 40px);
margin: 20px auto;
overflow-x: scroll;
overflow-y: hidden;
scroll-timeline: --carousel x;
overscroll-behavior: contain;
scroll-behavior: smooth;
scroll-snap-type: x mandatory; /* El scroll se hará de forma horizontal */
scrollbar-color: #c50000 transparent; /* El primer color es el color de la barra y el segundo es el color del fondo */
scrollbar-width: none; /* Ocultamos la barra de scroll */
border-radius: 2px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
&:hover {
scrollbar-width: thin; /* Mostramos la barra de scroll */
}
& > a {
flex: 0 0 100%;
scroll-snap-align: center; /* Hace que el scroll se alinee al centro de cada imagen */
}
img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
.markers {
display: flex;
justify-content: center;
gap: 10px;
list-style: none;
padding: 0;
li:nth-child(1) {
--i: 1;
}
li:nth-child(2) {
--i: 2;
}
li:nth-child(3) {
--i: 3;
}
li:nth-child(4) {
--i: 4;
}
li:nth-child(5) {
--i: 5;
}
a {
display: block;
width: 16px;
aspect-ratio: 1;
background: white;
opacity: .7;
border-radius: 50%;
animation: activate linear;
animation-timeline: --carousel;
animation-range: calc((var(--i) - 1) * 20%) calc(var(--i) * 20% + 1px);
}
}
}
@keyframes activate {
0%,
100% {
background: #c50000;
opacity: 1;
}
}
@media (prefers-color-scheme: dark) {
.slider {
scrollbar-color: #c4a603 transparent;
}
}
@media screen and (width > 768px) {
.container {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
h1 {
margin-top: 0;
}
.slider {
width: 500px;
}
}
}
</style>
</head>
<body>
<div class="container">
<h1>Scroll Gallery</h1>
<section class="slider">
<!-- Images will be added here -->
</section>
<ul class="markers">
<!-- Markers will be added here -->
</ul>
</div>
<script>
const images = [
"src/deadpool-and-wolverine-4k-wallpaper-uhdpaper.com-586@3@a.jpg",
"src/deadpool-and-wolverine-hand-heart-4k-wallpaper-uhdpaper.com-589@3@a.jpg",
"src/deadpool-and-wolverine-movie-poster-4k-wallpaper-uhdpaper.com-581@3@a.jpg",
"src/deadpool-and-wolverine-poster-4k-wallpaper-uhdpaper.com-582@3@a.jpg",
"src/deadpool-and-wolverine-poster-4k-wallpaper-uhdpaper.com-583@3@a.jpg"
];
const slider = document.querySelector(".slider");
images.forEach((image, i) => {
const slide = document.createElement("a");
slide.name = `slide-${i}`;
slide.innerHTML = `<img src="${image}" alt="image">`;
slider.appendChild(slide);
const markers = document.querySelector(".markers");
const marker = document.createElement("li");
marker.innerHTML = `<a href="#slide-${i}"></a>`;
markers.appendChild(marker);
});
</script>
</body>
</html>