<!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>
<style>
body{
background-color: #ccc;
}
.box{
width: 200px;
height: 100px;
background: url(../media/bear.png) no-repeat;
/* forwards维持结束状态 */
animation: run 1s steps(8) infinite,move 6s linear forwards; /* 8张图步骤抽8次,而不是匀速linear抽 速度曲线步长*/
}
@keyframes run {
0%{
background-position: 0 0;
}
100%{
background-position: -1600px 0; /* 从右抽到左,x轴变小 */
}
}
@keyframes move {
0%{
transform: translate(0,0);
}
100%{
transform: translate(600px,0)4;
}
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>