css实现奔跑的效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.box {
width: 180px;
height:300px;
border:2px solid #ccc;
left:45%;
position: relative;
}
.d1 {
width: 180px;
height: 300px;
position: absolute;
background:url(./img/charector.png) 0 0 no-repeat;
animation-name: move;
animation-duration: 950ms;
animation-iteration-count: infinite;
/* step-start 马上跳转到动画每一帧结束的位置 */
animation-timing-function: step-start;
}
@keyframes move {
0% {
background-position: 0 0;
}
14% {
background-position: -180px 0;
}
28% {
background-position: -360px 0;
}
42% {
background-position: -540px 0;
}
56% {
background-position: -720px 0;
}
70% {
background-position: -900px 0;
}
84% {
background-position: -1080px 0;
}
100% {
background-position: 0 0;
}
}
</style>
</head>
<body>
<div class="box">
<div class="d1"></div>
</div>
</body>
</html>
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634871.html