一个简单的小动画仿写
<!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>梦幻西游</title>
</head>
<style>
* {
margin: 0;
padding: 0;
}
html,body {
height: 100%;
overflow: hidden;
}
.back {
height: 100%;
width: 3920px;
background-image: url(./images/bg.jpg);
margin-left: -2000px;
animation: back_move 10s infinite linear;
}
/* 容器样式 */
.wrap {
height: 300px;
width: 790px;
position: absolute;
top: 45%;
left: 50%;
margin-left: -350px;
}
.wrap > div {
float: left;
}
/* 孙悟空的窗口 */
.wk {
width: 200px;
height: 180px;
overflow: hidden;
}
.wk div {
background-image: url(./images/wk.png);
height: 180px;
width: 1600px;
animation: wk_move 1s infinite steps(8);
}
/* 八戒的窗口 */
.bj {
width: 200px;
height: 180px;
overflow: hidden;
}
.bj div {
background-image: url(./images/bj.png);
height: 180px;
width: 1600px;
animation: bj_move 1s infinite steps(8);
}
/* 唐僧的窗口 */
.ts {
height: 240px;
width: 170px;
margin-top: -30px;
overflow: hidden;
}
.ts div {
background-image: url(./images/ts.png);
height: 240px;
width: 1360px ;
animation: ts_move 1s infinite steps(8);
}
/* 沙僧的窗口 */
.ss {
width: 210px;
height: 200px;
overflow: hidden;
}
.ss div {
background-image: url(./images/ss.png);
height: 200px;
width: 1680px;
animation: ss_move 1s infinite steps(8);
}
/* 背景图动画 */
@keyframes back_move {
from {
margin-left: -1920px;
}
to {
margin-left: 0;
}
}
/* 孙悟空 */
@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>
<body>
<!-- 背景图 -->
<div class="back"></div>
<!-- 容器 -->
<div class="wrap">
<div class="wk">
<div></div>
</div>
<div class="bj">
<div></div>
</div>
<div class="ts">
<div></div>
</div>
<div class="ss">
<div></div>
</div>
</div>
</body>
</html>