最近学习了用css写动画,写了一个梦幻西游的动画
HTML代码
`
CSS代码
*{
margin: 0;
padding: 0;
list-style: none;
}
.people{
position: absolute;
width: 950px;
left: 50%;
margin-left: -475px;
bottom: 100px;
}
.people>ul::after{
clear: both;
display: block;
content: “”;
}
.people>ul>li{
width: 200px;
height: 180px;
margin-right: 50px;
float: left;
overflow: hidden;
}
.people>ul>li:last-child{
margin-right: 0;
}
.people>ul>li>div{
width: 1600px;
height: 180px;
font-size: 0;
animation-name: dong;
animation-duration: 1s;
animation-iteration-count:infinite;
animation-timing-function: steps(8);
}
.people>ul>li>div>img{
width: 100%;
}
/定义动画/
@keyframes dong{
from{
margin-left: 0;
}
to{
margin-left: -1600px;
}
}
html,body,.main{
height: 100%;
}
.main{
position: relative;
width: 100%;
overflow: hidden;
}
.main>.background{
position: relative;
width: 3920px;
height: 100%;
background-image: url(’./images/bg.jpg’);
background-repeat: repeat-x;
animation-name: bg;
animation-duration: 30s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
@keyframes bg{
from{
left: -1920px;
}
to{
left: 0;
}
}