这是我学习了CSS的动画效果之后,动手练习的小案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>梦幻西游</title>
<style>
*{
margin: 0;
padding: 0;
}
html,body{
height: 100%;
overflow: hidden;
}
.back{
width: 3920px;
height: 100%;
background-image: url(./2.jpg);
margin-left: -2000px;
animation: back_move 25s infinite linear;
}
@keyframes back_move {
from{
margin-left: -1920px;
}
to{
margin-left: 0;
}
}
.content{
width: 1200px;
height: 400px;
position: absolute;
left: 20%;
top: 30%;
}
.wk{
width: 200px;
height: 180px;
float: left;
overflow: hidden;
}
.bj{
width: 200px;
height: 180px;
float: left;
overflow: hidden;
}
.ts{
width: 170px;
height: 240px;
float: left;
overflow: hidden;
}
.ss{
width: 210px;
height: 200px;
overflow: hidden;
}
.wk img{
height: 180px;
animation: wk_move 1s steps(8) infinite;
}
.bj img{
height: 180px;
animation: bj_move 1s steps(8) infinite;
}
.ts img{
height: 240px;
animation: ts_move 1s steps(8) infinite;
}
.ss img{
height: 200px;
animation: ss_move 1s steps(8) infinite;
}
@keyframes wk_move {
from{
margin-left: 0;
}
to{
margin-left: -1600px;
}
}
@keyframes bj_move {
from{
margin-left: 0;
}
to{
margin-left: -1600px;
}
}
@keyframes ts_move {
from{
margin-left: 0;
}
to{
margin-left: -1360px;
}
}
@keyframes ss_move {
from{
margin-left: 0;
}
to{
margin-left: -1680px;
}
}
</style>
</head>
<body>
<!-- 背景 -->
<div class="back">
<div class="content">
<!-- 悟空 -->
<div class="wk">
<!-- 悟空图片 -->
<img src="wk.png">
</div>
<!-- 八戒 -->
<div class="bj">
<!-- 八戒图片 -->
<img src="bj.png">
</div>
<!-- 唐僧 -->
<div class="ts">
<!-- 唐僧图片 -->
<img src="ts.png">
</div>
<!-- 沙僧 -->
<div class="ss">
<!-- 沙僧图片 -->
<img src="ss.png">
</div>
</div>
</div>
</body>
</html>
由于动图制作比较麻烦,这里就只放图片了
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/6a94fbbc9d27770774886025922a1d16.png#pic_center)