方法一

animation: donghau 5s steps(5) infinite;
margin-left: -500%;

<!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">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.box{
width: 100%;
height: 400px;
background-color: burlywood;
overflow: hidden;
}
.box>.bigbox{
width: 500%;
height: 400px;
background-color: rgb(180, 84, 84);
animation: donghau 5s steps(5) infinite;
}
.box>.bigbox>div{
width: 20%;
height: 400px;
font-size: 100px;
font-weight: bold;
text-align: center;
line-height: 400px;
float: left;
}
.box>.bigbox>div:nth-child(1){
background-color: rgb(210, 247, 199);
}
.box>.bigbox>div:nth-child(2){
background-color: rgb(248, 195, 195);
}
.box>.bigbox>div:nth-child(3){
background-color: rgb(198, 245, 239);
}
.box>.bigbox>div:nth-child(4){
background-color: rgb(216, 201, 235);
}
.box>.bigbox>div:nth-child(5){
background-color: rgb(243, 209, 220);
}


@keyframes donghau{
0%{
margin-left: 0;
}
100%{
margin-left: -500%;

}
}
</style>
</head>
<body>
<!-- 盒子:观看轮播图区域切换的窗口 -->
<div class="box">
<!-- 用来进行移动的 -->
<div class="bigbox">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
</div>
</body>
</html>

方法二

animation: donghau 5s steps(5) infinite;
transform: translate(-100%);

<!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">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.box{
width: 100%;
height: 400px;
background-color: burlywood;
overflow: hidden;
}
.box>.bigbox{
width: 500%;
height: 400px;
background-color: rgb(180, 84, 84);
animation: donghau 5s steps(5) infinite;
}
.box>.bigbox>div{
width: 20%;
height: 400px;
font-size: 100px;
font-weight: bold;
text-align: center;
line-height: 400px;
float: left;
}
.box>.bigbox>div:nth-child(1){
background-color: rgb(210, 247, 199);
}
.box>.bigbox>div:nth-child(2){
background-color: rgb(248, 195, 195);
}
.box>.bigbox>div:nth-child(3){
background-color: rgb(198, 245, 239);
}
.box>.bigbox>div:nth-child(4){
background-color: rgb(216, 201, 235);
}
.box>.bigbox>div:nth-child(5){
background-color: rgb(243, 209, 220);
}


@keyframes donghau{
0%{
margin-left: 0;
}
100%{

transform: translate(-100%);
}
}
</style>
</head>
<body>
<!-- 盒子:观看轮播图区域切换的窗口 -->
<div class="box">
<!-- 用来进行移动的 -->
<div class="bigbox">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
</div>
</body>
</html>

[css3] 小案例---动画版轮播图(屏幕宽度)_轮播图


[css3] 小案例---动画版轮播图(屏幕宽度)_html_02