源码:
<input type="radio" name="slider" id="slide-a-1" checked>
<input type="radio" name="slider" id="slide-a-2">
<input type="radio" name="slider" id="slide-a-3">
<input type="radio" name="slider" id="slide-a-4">
<input type="radio" name="slider" id="slide-a-5">
<input type="radio" name="slider" id="slide-b-1">
<input type="radio" name="slider" id="slide-b-2">
<input type="radio" name="slider" id="slide-b-3">
<input type="radio" name="slider" id="slide-b-4">
<input type="radio" name="slider" id="slide-b-5">
<div class="slider a1 aa1"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<div class="slider a2 aa2"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<div class="slider a3 aa3"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<div class="slider a4 aa4"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<div class="slider a5 aa5"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<div class="slider a1 bb1"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<div class="slider a2 bb2"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<div class="slider a3 bb3"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<div class="slider a4 bb4"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<div class="slider a5 bb5"><ul><li></li><li></li><li></li><li></li><li></li></ul></div>
<nav><label for="slide-a-1"></label><label for="slide-a-2"></label><label for="slide-a-3"></label><label for="slide-a-4"></label><label for="slide-a-5"></label><label for="slide-b-1"></label><label for="slide-b-2"></label><label for="slide-b-3"></label><label for="slide-b-4"></label><label for="slide-b-5"></label></nav>
<style>
html {
background-color: #eee;
}
.slider,
.slider > ul,
.slider > ul > li {
position: absolute;
width: 500px;
height: 300px;
list-style-type: none;
margin: 0;
padding: 0;
}
.slider {
display: none;
overflow: hidden;
left: calc(50% - 250px);
top: calc(50% - 150px);
border: 8px solid #fff;
border-radius: 3px;
box-sizing: content-box;
}
.slider > ul > li:nth-child(1) {
background: url("https://picsum.photos/id/230/500/300");
}
.slider > ul > li:nth-child(2) {
background: url("https://picsum.photos/id/250/500/300");
}
.slider > ul > li:nth-child(3) {
background: url("https://picsum.photos/id/350/500/300");
}
.slider > ul > li:nth-child(4) {
background: url("https://picsum.photos/id/450/500/300");
}
.slider > ul > li:nth-child(5) {
background: url("https://picsum.photos/id/550/500/300");
}
.slider > ul > li {
background-position: center center !important;
background-repeat: no-repeat !important;
background-size: cover !important;
}
nav {
position: absolute;
width: 165px;
height: 15px;
left: calc(50% - 77.5px);
top: calc(50% + 180px);
overflow: hidden;
}
input {
display: none;
}
label {
cursor: pointer;
position: absolute;
z-index: 5;
background: #ccc;
display: block;
width: 15px;
height: 15px;
border-radius: 50%;
}
label:nth-child(1),
label:nth-child(6) {
left: 15px;
}
label:nth-child(2),
label:nth-child(7) {
left: 45px;
}
label:nth-child(3),
label:nth-child(8) {
left: 75px;
}
label:nth-child(4),
label:nth-child(9) {
left: 105px;
}
label:nth-child(5),
label:nth-child(10) {
left: 135px;
}
.a1 > ul > li:nth-child(1),
.a2 > ul > li:nth-child(2),
.a3 > ul > li:nth-child(3),
.a4 > ul > li:nth-child(4),
.a5 > ul > li:nth-child(5) {
animation: opacity-0 10s ease infinite 2s;
z-index: 10;
}
.a1 > ul > li:nth-child(2),
.a2 > ul > li:nth-child(3),
.a3 > ul > li:nth-child(4),
.a4 > ul > li:nth-child(5),
.a5 > ul > li:nth-child(1) {
animation: opacity-0 10s ease infinite 4s;
z-index: 9;
}
.a1 > ul > li:nth-child(3),
.a2 > ul > li:nth-child(4),
.a3 > ul > li:nth-child(5),
.a4 > ul > li:nth-child(1),
.a5 > ul > li:nth-child(2) {
animation: opacity-0 10s ease infinite 6s;
z-index: 8;
}
.a1 > ul > li:nth-child(4),
.a2 > ul > li:nth-child(5),
.a3 > ul > li:nth-child(1),
.a4 > ul > li:nth-child(2),
.a5 > ul > li:nth-child(3) {
animation: opacity-0 10s ease infinite 8s;
z-index: 7;
}
.a1 > ul > li:nth-child(5),
.a2 > ul > li:nth-child(1),
.a3 > ul > li:nth-child(2),
.a4 > ul > li:nth-child(3),
.a5 > ul > li:nth-child(4) {
animation: opacity-0 10s ease infinite 10s;
z-index: 6;
}
#slide-a-1:checked ~ .aa1,
#slide-a-2:checked ~ .aa2,
#slide-a-3:checked ~ .aa3,
#slide-a-4:checked ~ .aa4,
#slide-a-5:checked ~ .aa5,
#slide-b-1:checked ~ .bb1,
#slide-b-2:checked ~ .bb2,
#slide-b-3:checked ~ .bb3,
#slide-b-4:checked ~ .bb4,
#slide-b-5:checked ~ .bb5 {
display: block;
}
#slide-a-1:checked ~ nav label:nth-child(6),
#slide-a-1:checked ~ nav label:nth-child(7),
#slide-a-1:checked ~ nav label:nth-child(8),
#slide-a-1:checked ~ nav label:nth-child(9),
#slide-a-1:checked ~ nav label:nth-child(10),
#slide-a-2:checked ~ nav label:nth-child(6),
#slide-a-2:checked ~ nav label:nth-child(7),
#slide-a-2:checked ~ nav label:nth-child(8),
#slide-a-2:checked ~ nav label:nth-child(9),
#slide-a-2:checked ~ nav label:nth-child(10),
#slide-a-3:checked ~ nav label:nth-child(6),
#slide-a-3:checked ~ nav label:nth-child(7),
#slide-a-3:checked ~ nav label:nth-child(8),
#slide-a-3:checked ~ nav label:nth-child(9),
#slide-a-3:checked ~ nav label:nth-child(10),
#slide-a-4:checked ~ nav label:nth-child(6),
#slide-a-4:checked ~ nav label:nth-child(7),
#slide-a-4:checked ~ nav label:nth-child(8),
#slide-a-4:checked ~ nav label:nth-child(9),
#slide-a-4:checked ~ nav label:nth-child(10),
#slide-a-5:checked ~ nav label:nth-child(6),
#slide-a-5:checked ~ nav label:nth-child(7),
#slide-a-5:checked ~ nav label:nth-child(8),
#slide-a-5:checked ~ nav label:nth-child(9),
#slide-a-5:checked ~ nav label:nth-child(10),
#slide-b-1:checked ~ nav label:nth-child(1),
#slide-b-1:checked ~ nav label:nth-child(2),
#slide-b-1:checked ~ nav label:nth-child(3),
#slide-b-1:checked ~ nav label:nth-child(4),
#slide-b-1:checked ~ nav label:nth-child(5),
#slide-b-2:checked ~ nav label:nth-child(1),
#slide-b-2:checked ~ nav label:nth-child(2),
#slide-b-2:checked ~ nav label:nth-child(3),
#slide-b-2:checked ~ nav label:nth-child(4),
#slide-b-2:checked ~ nav label:nth-child(5),
#slide-b-3:checked ~ nav label:nth-child(1),
#slide-b-3:checked ~ nav label:nth-child(2),
#slide-b-3:checked ~ nav label:nth-child(3),
#slide-b-3:checked ~ nav label:nth-child(4),
#slide-b-3:checked ~ nav label:nth-child(5),
#slide-b-4:checked ~ nav label:nth-child(1),
#slide-b-4:checked ~ nav label:nth-child(2),
#slide-b-4:checked ~ nav label:nth-child(3),
#slide-b-4:checked ~ nav label:nth-child(4),
#slide-b-4:checked ~ nav label:nth-child(5),
#slide-b-5:checked ~ nav label:nth-child(1),
#slide-b-5:checked ~ nav label:nth-child(2),
#slide-b-5:checked ~ nav label:nth-child(3),
#slide-b-5:checked ~ nav label:nth-child(4),
#slide-b-5:checked ~ nav label:nth-child(5) {
top: 0;
}
#slide-a-1:checked ~ nav label:nth-child(1),
#slide-a-1:checked ~ nav label:nth-child(2),
#slide-a-1:checked ~ nav label:nth-child(3),
#slide-a-1:checked ~ nav label:nth-child(4),
#slide-a-1:checked ~ nav label:nth-child(5),
#slide-a-2:checked ~ nav label:nth-child(1),
#slide-a-2:checked ~ nav label:nth-child(2),
#slide-a-2:checked ~ nav label:nth-child(3),
#slide-a-2:checked ~ nav label:nth-child(4),
#slide-a-2:checked ~ nav label:nth-child(5),
#slide-a-3:checked ~ nav label:nth-child(1),
#slide-a-3:checked ~ nav label:nth-child(2),
#slide-a-3:checked ~ nav label:nth-child(3),
#slide-a-3:checked ~ nav label:nth-child(4),
#slide-a-3:checked ~ nav label:nth-child(5),
#slide-a-4:checked ~ nav label:nth-child(1),
#slide-a-4:checked ~ nav label:nth-child(2),
#slide-a-4:checked ~ nav label:nth-child(3),
#slide-a-4:checked ~ nav label:nth-child(4),
#slide-a-4:checked ~ nav label:nth-child(5),
#slide-a-5:checked ~ nav label:nth-child(1),
#slide-a-5:checked ~ nav label:nth-child(2),
#slide-a-5:checked ~ nav label:nth-child(3),
#slide-a-5:checked ~ nav label:nth-child(4),
#slide-a-5:checked ~ nav label:nth-child(5),
#slide-b-1:checked ~ nav label:nth-child(6),
#slide-b-1:checked ~ nav label:nth-child(7),
#slide-b-1:checked ~ nav label:nth-child(8),
#slide-b-1:checked ~ nav label:nth-child(9),
#slide-b-1:checked ~ nav label:nth-child(10),
#slide-b-2:checked ~ nav label:nth-child(6),
#slide-b-2:checked ~ nav label:nth-child(7),
#slide-b-2:checked ~ nav label:nth-child(8),
#slide-b-2:checked ~ nav label:nth-child(9),
#slide-b-2:checked ~ nav label:nth-child(10),
#slide-b-3:checked ~ nav label:nth-child(6),
#slide-b-3:checked ~ nav label:nth-child(7),
#slide-b-3:checked ~ nav label:nth-child(8),
#slide-b-3:checked ~ nav label:nth-child(9),
#slide-b-3:checked ~ nav label:nth-child(10),
#slide-b-4:checked ~ nav label:nth-child(6),
#slide-b-4:checked ~ nav label:nth-child(7),
#slide-b-4:checked ~ nav label:nth-child(8),
#slide-b-4:checked ~ nav label:nth-child(9),
#slide-b-4:checked ~ nav label:nth-child(10),
#slide-b-5:checked ~ nav label:nth-child(6),
#slide-b-5:checked ~ nav label:nth-child(7),
#slide-b-5:checked ~ nav label:nth-child(8),
#slide-b-5:checked ~ nav label:nth-child(9),
#slide-b-5:checked ~ nav label:nth-child(10) {
top: 15px;
}
#slide-a-1:checked ~ nav label:nth-child(6),
#slide-a-2:checked ~ nav label:nth-child(7),
#slide-a-3:checked ~ nav label:nth-child(8),
#slide-a-4:checked ~ nav label:nth-child(9),
#slide-a-5:checked ~ nav label:nth-child(10),
#slide-b-1:checked ~ nav label:nth-child(1),
#slide-b-2:checked ~ nav label:nth-child(2),
#slide-b-3:checked ~ nav label:nth-child(3),
#slide-b-4:checked ~ nav label:nth-child(4),
#slide-b-5:checked ~ nav label:nth-child(5) {
animation: bg-1 10s ease infinite;
}
#slide-a-1:checked ~ nav > label:nth-child(7),
#slide-a-2:checked ~ nav > label:nth-child(8),
#slide-a-3:checked ~ nav > label:nth-child(9),
#slide-a-4:checked ~ nav > label:nth-child(10),
#slide-a-5:checked ~ nav > label:nth-child(6),
#slide-b-1:checked ~ nav > label:nth-child(2),
#slide-b-2:checked ~ nav > label:nth-child(3),
#slide-b-3:checked ~ nav > label:nth-child(4),
#slide-b-4:checked ~ nav > label:nth-child(5),
#slide-b-5:checked ~ nav > label:nth-child(1) {
animation: bg 10s ease infinite;
}
#slide-a-1:checked ~ nav > label:nth-child(8),
#slide-a-2:checked ~ nav > label:nth-child(9),
#slide-a-3:checked ~ nav > label:nth-child(10),
#slide-a-4:checked ~ nav > label:nth-child(6),
#slide-a-5:checked ~ nav > label:nth-child(7),
#slide-b-1:checked ~ nav > label:nth-child(3),
#slide-b-2:checked ~ nav > label:nth-child(4),
#slide-b-3:checked ~ nav > label:nth-child(5),
#slide-b-4:checked ~ nav > label:nth-child(1),
#slide-b-5:checked ~ nav > label:nth-child(2) {
animation: bg 10s ease infinite 2s;
}
#slide-a-1:checked ~ nav > label:nth-child(9),
#slide-a-2:checked ~ nav > label:nth-child(10),
#slide-a-3:checked ~ nav > label:nth-child(6),
#slide-a-4:checked ~ nav > label:nth-child(7),
#slide-a-5:checked ~ nav > label:nth-child(8),
#slide-b-1:checked ~ nav > label:nth-child(4),
#slide-b-2:checked ~ nav > label:nth-child(5),
#slide-b-3:checked ~ nav > label:nth-child(1),
#slide-b-4:checked ~ nav > label:nth-child(2),
#slide-b-5:checked ~ nav > label:nth-child(3) {
animation: bg 10s ease infinite 4s;
}
#slide-a-1:checked ~ nav > label:nth-child(10),
#slide-a-2:checked ~ nav > label:nth-child(6),
#slide-a-3:checked ~ nav > label:nth-child(7),
#slide-a-4:checked ~ nav > label:nth-child(8),
#slide-a-5:checked ~ nav > label:nth-child(9),
#slide-b-1:checked ~ nav > label:nth-child(5),
#slide-b-2:checked ~ nav > label:nth-child(1),
#slide-b-3:checked ~ nav > label:nth-child(2),
#slide-b-4:checked ~ nav > label:nth-child(3),
#slide-b-5:checked ~ nav label:nth-child(4) {
animation: bg 10s ease infinite 6s;
}
@keyframes bg-1 {
0%,21%,100% {
background: #ccc;
}
0%,20% {
background: #333;
}
}
@keyframes bg {
0%,19%,41%,100% {
background: #ccc;
}
20%,40% {
background: #333;
}
}
@keyframes opacity-0 {
0%,20%,80%,100% {
opacity: 1;
}
20%,80% {
opacity: 0;
}
}
</style>