gpt4 book ai didi

javascript - 循环后暂停 css sprite 一秒钟

转载 作者:行者123 更新时间:2023-11-30 23:45:59 27 4
gpt4 key购买 nike

有什么办法(使用CSS)在最后一步之后将 Sprite 暂停一秒或多秒?我尝试再添加一个步骤或将相同的背景位置从 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>

关于javascript - 循环后暂停 css sprite 一秒钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34989940/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com