轮播图html代码
<div class="container">
<div class="box">
<img src="img/1.jpg" alt="" >
<img src="img/2.jpg" alt="" >
<img src="img/3.jpg" alt="" >
<img src="img/4.jpg" alt="" >
<img src="img/1.jpg" alt="" >
</div>
<div class="wrapper">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
</div>
轮播图css代码
* {
margin: 0;
padding: 0;
}
.container {
width: 100%;
height: 450px;
position: relative;
overflow: hidden;
}
.container .box {
width: 500%;
height: 450px;
background-color: #ccc;
display: flex;
margin-left: 0px;
animation: move 20s linear infinite;
}
.container .box img {
width: 20%;
height: 450px;
}
.container .wrapper {
position: absolute;
bottom: 30px;
left: 0;
width: 100%;
display: flex;
justify-content: center;
}
.container .wrapper .circle {
width: 10px;
height: 10px;
border: 1px solid red;
margin: 0 10px;
border-radius: 50%;
animation: circleshow 20s linear infinite;
}
.container .wrapper .circle:nth-child(2) {
animation: circleshow 20s linear 5s infinite;
}
.container .wrapper .circle:nth-child(3) {
animation: circleshow 20s linear 10s infinite;
}
.container .wrapper .circle:nth-child(4) {
animation: circleshow 20s linear 15s infinite;
}
@keyframes move {
0% {
margin-left: 0%;
}
20% {
margin-left: 0%;
}
25% {
margin-left: -100%;
}
45% {
margin-left: -100%;
}
50% {
margin-left: -200%;
}
70% {
margin-left: -200%;
}
75% {
margin-left: -300%;
}
95% {
margin-left: -300%;
}
100% {
margin-left: -400%;
}
}
@keyframes circleshow {
0% {
background-color: white;
}
20% {
background-color: white;
}
25% {
background-color: transparent;
}
100% {
background-color: transparent;
}
}