效果图
原图
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>steps</title>
<style>
.box {
width: 266px;
height: 241px;
border: 1px solid;
background-image: url("img/天宫.jpg");
animation: run 1s steps(7) infinite;
}
@keyframes run {
to {
background-position: -1862px 0;
}
}
</style>
</head>
<body>
<div class="box">
</div>
</body>
</html>
要点:
1、从第一个图到第8个图需要经过7步——steps(7)
2、从第一个图位移到第八个图需要经过1862px