<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.box {
width: 180px;
height: 300px;
background: yellowgreen url(./img1/charector.png) no-repeat;
animation: mp 0.5s step-start infinite;
}
/* step-star
忽略了中间的变化过程,直接从当前帧开始的地方跳转到下一个关键帧开始的地方 */
@keyframes mp {
0% {
background-position: 0 0;
}
16% {
background-position: -180px 0;
}
33% {
background-position: -360px 0;
}
50% {
background-position: -540px 0;
}
66% {
background-position: -720px 0;
}
83% {
background-position: -900px 0;
}
100% {
background-position: -1080px 0;
}
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
效果如下: