-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcarousel.css
60 lines (51 loc) · 1.02 KB
/
carousel.css
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
.carousel {
--width: 90vw;
--slide: 0;
margin: 0 auto;
overflow: hidden;
margin-bottom: 16px;
width: var(--width);
& .track {
display: flex;
width: max-content;
transition: 400ms cubic-bezier(0.47, 0, 0.745, 0.715);
transform: translateX(calc(-1 * var(--slide) * var(--width)));
& .slide {
& .image {
width: var(--width);
aspect-ratio: 16/9;
}
& .caption {
font-size: 70%;
}
}
}
& .switch-panel {
display: flex;
justify-content: center;
gap: 8px;
margin-top: 8px;
& .switch {
--l: 80%;
appearance: none;
display: block;
width: 1rem;
aspect-ratio: 1;
border-radius: 50%;
background-color: hsl(190deg, 36%, var(--l));
&:checked {
--l: 20%;
}
}
}
/* Trigger slide change */
&:has(.switch:nth-of-type(2):checked) {
--slide: 1;
}
&:has(.switch:nth-of-type(3):checked) {
--slide: 2;
}
&:has(.switch:nth-of-type(4):checked) {
--slide: 3;
}
}