有没有办法(使用CSS)在最后一步之后将精灵暂停一秒或更长时间?我尝试将步长或相同的bg位置从80%添加到100%,但没有用。
.sprite {
animation: anim 2000ms steps(16) infinite;
background: url(http://i.imgur.com/9FprJ5C.png) left center no-repeat;
height: 45px;
width: 90px;
}
@keyframes anim {
0% {
background-position: 0px 0;
}
80% {
background-position: -1440px 0px;
}
100% {
background-position: -1440px 0px;
}
}
<div class="sprite"></div>
您是否尝试过使动画达到50%的结尾?即1秒钟后从50%-100%暂停:
@keyframes anim {
0% {
background-position: 0px 0;
}
50% {
background-position: -1440px 0px;
}
100% {
background-position: -1440px 0px;
}
}
.sprite {
animation: anim 2000ms steps(16) infinite;
background: url(http://i.imgur.com/9FprJ5C.png) left center no-repeat;
height: 45px;
width: 90px;
}
@keyframes anim {
0% {
background-position: 0px 0;
}
50% {
background-position: -1440px 0px;
}
100% {
background-position: -1440px 0px;
}
}
<div class="sprite"></div>