-
Notifications
You must be signed in to change notification settings - Fork 14
/
018.轮播图.html
119 lines (100 loc) · 3.08 KB
/
018.轮播图.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./assets/global.css">
<style>
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
ul.slides {
position: relative;
width: 600px;
height: 280px;
list-style: none;
padding: 0;
margin: 0;
background-color: #eee;
overflow: hidden;
}
li.slide {
margin: 0;
padding: 0;
width: inherit;
position: absolute;
top: 0;
transition: .5s transform ease-in-out;
}
.slide:nth-of-type(1) {
left: 100%;
}
.slide:nth-of-type(2) {
left: 200%;
}
input[type='radio'] {
position: relative;
z-index: 100;
display: none;
}
.controls-visible {
position: absolute;
width: 100%;
bottom: 24px;
text-align: center;
}
.controls-visible label {
display: inline-block;
width: 10px;
height: 10px;
background-color: #fff;
border-radius: 50%;
margin: 0 3px;
border: 2px solid #fff;
}
.slides input[type='radio']:nth-of-type(1):checked~.controls-visible label:nth-of-type(1) {
background-color: #333;
}
.slides input[type='radio']:nth-of-type(2):checked~.controls-visible label:nth-of-type(2) {
background-color: #333;
}
.slides input[type='radio']:nth-of-type(3):checked~.controls-visible label:nth-of-type(3) {
background-color: #333;
}
.slides input[type='radio']:nth-of-type(1):checked~.slide {
transform: translateX(0%);
}
.slides input[type='radio']:nth-of-type(2):checked~.slide {
transform: translateX(-100%);
}
.slides input[type='radio']:nth-of-type(3):checked~.slide {
transform: translateX(-200%);
}
</style>
</head>
<body>
<ul class="slides">
<input type="radio" name="control" id="control-1" checked>
<input type="radio" name="control" id="control-2">
<input type="radio" name="control" id="control-3">
<li class="slide">
<img src="https://picsum.photos/600/280?random=1" alt="">
</li>
<li class="slide">
<img src="https://picsum.photos/600/280?random=2" alt="">
</li>
<li class="slide">
<img src="https://picsum.photos/600/280?random=3" alt="">
</li>
<div class="controls-visible">
<label for="control-1"></label>
<label for="control-2"></label>
<label for="control-3"></label>
</div>
</ul>
</body>
</html>