
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>纯CSS实现轮播图(自动轮播)title>
<style>
.banner-container{
width:1200px;
height:400px;
margin:1rem auto;
overflow: hidden;
position: relative;
}
.banner-container .banner-img-container {
width:6000px;
height:400px;
overflow: hidden;
position: absolute;
display: flex;
animation: run 10s ease infinite;
}
.banner-container .banner-img-container img{
width:1200px;
height:100%;
}
@keyframes run {
0%,10%{
transform: translateX(0);
}
20%,30%{
transform: translateX(-1200px);
}
40%,50%{
transform: translateX(-2400px);
}
60%,70%{
transform: translateX(-3600px);
}
80%,90%{
transform: translateX(-4800px);
}
100%{
transform: translateX(0);
}
}
style>
head>
<body>
<div class="banner-container">
<div class="banner-img-container">
<img src="https://i1.mifile.cn/a4/xmad_15648327213423_KQdjZ.jpg" alt="">
<img src="https://i1.mifile.cn/a4/xmad_15648844833902_qXyxW.jpg" alt="">
<img src="https://i1.mifile.cn/a4/xmad_15650061412258_gjQPE.jpg" alt="">
<img src="https://i1.mifile.cn/a4/xmad_15627255042708_pFaEU.jpg" alt="">
<img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/08a499505c6850bee6f2bafa04688b26.jpg" alt="">
div>
div>
body>
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