CSS CSS动画延迟重复
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13887889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS animation delay in repeating
提问by Niet the Dark Absol
I've recently discovered how to "properly" use CSS animations (previously I dismissed them as not being able to make complex sequences like you could in JavaScript). So now I'm learning about them.
我最近发现了如何“正确”使用 CSS 动画(之前我认为它们无法像在 JavaScript 中那样制作复杂的序列而不予理会)。所以现在我正在了解他们。
For this effect, I'm trying to have a gradient "flare" sweep across a progress bar-like element. Similar to the effect on native Windows Vista/7 progress bars.
对于这种效果,我试图在类似进度条的元素上进行渐变“耀斑”扫掠。类似于对原生 Windows Vista/7 进度条的影响。
@keyframes barshine {
from {background-image:linear-gradient(120deg,rgba(255,255,255,0) -10%,rgba(255,255,255,0.25) -5%,rgba(255,255,255,0) 0%);}
to {background-image:linear-gradient(120deg,rgba(255,255,255,0) 100%,rgba(255,255,255,0.25) 105%,rgba(255,255,255,0) 110%);}
}
.progbar {
animation: barshine 1s 4s linear infinite;
}
As you can see, I am trying to have a delay of 4 seconds, followed by the shine sweeping across in 1 second, repeated.
正如你所看到的,我试图延迟 4 秒,然后在 1 秒内扫过光芒,重复。
However, it seems that the animation-delay
only applies to the first iteration, after which the shine just keeps sweeping across repeatedly.
然而,似乎animation-delay
只适用于第一次迭代,之后闪耀只是不断地反复扫过。
I "resolved" this issue as follows:
我“解决”了这个问题如下:
@keyframes expbarshine {
from {background-image:linear-gradient(120deg,rgba(255,255,255,0) -10%,rgba(255,255,255,0.25) -5%,rgba(255,255,255,0) 0%);}
80% {background-image:linear-gradient(120deg,rgba(255,255,255,0) -10%,rgba(255,255,255,0.25) -5%,rgba(255,255,255,0) 0%);}
to {background-image:linear-gradient(120deg,rgba(255,255,255,0) 100%,rgba(255,255,255,0.25) 105%,rgba(255,255,255,0) 110%);}
}
.progbar {
animation: barshine 5s linear infinite;
}
from
and 80%
are exactly the same, resulting in a "delay" of 80% of the animation length.
from
并且80%
完全相同,导致动画长度的“延迟”为 80%。
This works, but for my next animation, I need the delay to be variable (constant for a particular element, but variable among elements that use the animation), while the animation itself stays exactly the same length.
这有效,但对于我的下一个动画,我需要延迟是可变的(对于特定元素是恒定的,但在使用动画的元素之间是可变的),而动画本身保持完全相同的长度。
With the above "solution", I would end up with a slower animation when all I want is a longer delay.
使用上面的“解决方案”,当我想要的只是更长的延迟时,我最终会得到一个较慢的动画。
Is it possible to have the animation-delay
apply to all iterations, rather than just the first?
是否可以将animation-delay
应用应用于所有迭代,而不仅仅是第一次?
回答by Sebastian Thomas
I had a similar problem and used
我有一个类似的问题并使用
@-webkit-keyframes pan {
0%, 10% { -webkit-transform: translate3d( 0%, 0px, 0px); }
90%, 100% { -webkit-transform: translate3d(-50%, 0px, 0px); }
}
Bit irritating that you have to fake your duration to account for 'delays' at either end.
有点令人恼火的是,您必须伪造持续时间以考虑两端的“延迟”。
回答by tim
minitech is right in that animation-delay
specifies the delay before the animation starts and NOTthe delay in between iterations. The editors draft of the specdescribes it well and there was a discussion of this feature you're describing herewhich suggesting this iteration delay feature.
minitech 是正确的,它animation-delay
指定了动画开始之前的延迟,而不是迭代之间的延迟。 规范的编辑草案对其进行了很好的描述,并且对您在此处描述的此功能进行了讨论,其中建议此迭代延迟功能。
While there may be a workaround in JS, you can fake this iteration delay for the progress bar flare using only CSS.
虽然 JS 中可能有解决方法,但您可以仅使用 CSS 来伪造进度条耀斑的迭代延迟。
By declaring the flare div position:absolute
and the parent div overflow: hidden
, setting the 100% keyframe state greater than the width of the progress bar, and playing around with the cubic-bezier timing functionand left offset values, you're able to emulate an ease-in-out
or linear
timing with a "delay".
通过声明耀斑 divposition:absolute
和父 div overflow: hidden
,将 100% 关键帧状态设置为大于进度条的宽度,并使用三次贝塞尔计时函数和左偏移值,您可以模拟ease-in-out
或linear
计时延迟”。
It'd be interesting to write a less/scss mixin to calculate exactly the left offset and timing function to get this exact, but I don't have the time at the moment to fiddle with it. Would love to see something like that though!
编写一个 less/scss mixin 来精确计算左偏移量和计时函数以获得精确值会很有趣,但我现在没有时间摆弄它。虽然很想看到这样的东西!
Here's a demo I threw together to show this off. (I tried to emulate the windows 7 progress bar and fell a bit short, but it demonstrates what I'm talking about)
这是我拼凑起来的一个演示来展示这一点。(我试图模拟 Windows 7 进度条,但有点短,但它展示了我在说什么)
Demo: http://codepen.io/timothyasp/full/HlzGu
演示:http: //codepen.io/timothyasp/full/HlzGu
<!-- HTML -->
<div class="bar">
<div class="progress">
<div class="flare"></div>
</div>
</div>
/* CSS */
@keyframes progress {
from {
width: 0px;
}
to {
width: 600px;
}
}
@keyframes barshine {
0% {
left: -100px;
}
100% {
left: 1000px;
}
}
.flare {
animation-name: barshine;
animation-duration: 3s;
animation-direction: normal;
animation-fill-mode: forwards;
animation-timing-function: cubic-bezier(.14, .75, .2, 1.01);
animation-iteration-count: infinite;
left: 0;
top: 0;
height: 40px;
width: 100px;
position: absolute;
background: -moz-radial-gradient(center, ellipse cover, rgba(255,255,255,0.69) 0%, rgba(255,255,255,0) 87%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(255,255,255,0.69)), color-stop(87%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover, rgba(255,255,255,0.69) 0%,rgba(255,255,255,0) 87%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover, rgba(255,255,255,0.69) 0%,rgba(255,255,255,0) 87%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover, rgba(255,255,255,0.69) 0%,rgba(255,255,255,0) 87%); /* IE10+ */
background: radial-gradient(ellipse at center, rgba(255,255,255,0.69) 0%,rgba(255,255,255,0) 87%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b0ffffff', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
z-index: 10;
}
.progress {
animation-name: progress;
animation-duration: 10s;
animation-delay: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
overflow: hidden;
position:relative;
z-index: 1;
height: 100%;
width: 100%;
border-right: 1px solid #0f9116;
background: #caf7ce; /* Old browsers */
background: -moz-linear-gradient(top, #caf7ce 0%, #caf7ce 18%, #3fe81e 45%, #2ab22a 96%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#caf7ce), color-stop(18%,#caf7ce), color-stop(45%,#3fe81e), color-stop(96%,#2ab22a)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #caf7ce 0%,#caf7ce 18%,#3fe81e 45%,#2ab22a 96%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #caf7ce 0%,#caf7ce 18%,#3fe81e 45%,#2ab22a 96%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #caf7ce 0%,#caf7ce 18%,#3fe81e 45%,#2ab22a 96%); /* IE10+ */
background: linear-gradient(to bottom, #caf7ce 0%,#caf7ce 18%,#3fe81e 45%,#2ab22a 96%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#caf7ce', endColorstr='#2ab22a',GradientType=0 ); /* IE6-9 */
}
.progress:after {
content: "";
width: 100%;
height: 29px;
right: 0;
bottom: 0;
position: absolute;
z-index: 3;
background: -moz-linear-gradient(left, rgba(202,247,206,0) 0%, rgba(42,178,42,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(202,247,206,0)), color-stop(100%,rgba(42,178,42,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(202,247,206,0) 0%,rgba(42,178,42,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(202,247,206,0) 0%,rgba(42,178,42,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(202,247,206,0) 0%,rgba(42,178,42,1) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(202,247,206,0) 0%,rgba(42,178,42,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00caf7ce', endColorstr='#2ab22a',GradientType=1 ); /* IE6-9 */
}
.bar {
margin-top: 30px;
height: 40px;
width: 600px;
position: relative;
border: 1px solid #777;
border-radius: 3px;
}
回答by TalkativeTree
This is what you should do. It should work in that you have a 1 second animation, then a 4 second delay between iterations:
这是你应该做的。它应该可以工作,因为您有 1 秒的动画,然后在迭代之间有 4 秒的延迟:
@keyframes barshine {
0% {
background-image:linear-gradient(120deg,rgba(255,255,255,0) 0%,rgba(255,255,255,0.25) -5%,rgba(255,255,255,0) 0%);
}
20% {
background-image:linear-gradient(120deg,rgba(255,255,255,0) 10%,rgba(255,255,255,0.25) 105%,rgba(255,255,255,0) 110%);
}
}
.progbar {
animation: barshine 5s 0s linear infinite;
}
So I've been messing around with this a lot and you can do it without being very hacky. This is the simplest way to put in a delay between animation iterations that's 1. SUPER EASY and 2. just takes a little logic. Check out this dance animation I've made:
所以我一直在处理这个问题,你可以做到这一点而不会很笨拙。这是在动画迭代之间设置延迟的最简单方法,即 1. SUPER EASY 和 2. 只需要一点逻辑。看看我制作的这个舞蹈动画:
.dance{
animation-name: dance;
-webkit-animation-name: dance;
animation-iteration-count: infinite;
-webkit-animation-iteration-count: infinite;
animation-duration: 2.5s;
-webkit-animation-duration: 2.5s;
-webkit-animation-delay: 2.5s;
animation-delay: 2.5s;
animation-timing-function: ease-in;
-webkit-animation-timing-function: ease-in;
}
@keyframes dance {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
25% {
-webkit-transform: rotate(-120deg);
-moz-transform: rotate(-120deg);
-o-transform: rotate(-120deg);
-ms-transform: rotate(-120deg);
transform: rotate(-120deg);
}
50% {
-webkit-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-o-transform: rotate(20deg);
-ms-transform: rotate(20deg);
transform: rotate(20deg);
}
100% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
}
@-webkit-keyframes dance {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
20% {
-webkit-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-o-transform: rotate(20deg);
-ms-transform: rotate(20deg);
transform: rotate(20deg);
}
40% {
-webkit-transform: rotate(-120deg);
-moz-transform: rotate(-120deg);
-o-transform: rotate(-120deg);
-ms-transform: rotate(-120deg);
transform: rotate(-120deg);
}
60% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
80% {
-webkit-transform: rotate(-120deg);
-moz-transform: rotate(-120deg);
-o-transform: rotate(-120deg);
-ms-transform: rotate(-120deg);
transform: rotate(-120deg);
}
95% {
-webkit-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-o-transform: rotate(20deg);
-ms-transform: rotate(20deg);
transform: rotate(20deg);
}
}
I actually came here trying to figure out how to put a delay in the animation, when I realized that you just 1. extend the duration of the animation and shirt the proportion of time for each animation. Beore I had them each lasting .5 seconds for the total duration of 2.5 seconds. Now lets say i wanted to add a delay equal to the total duration, so a 2.5 second delay.
我实际上是想弄清楚如何在动画中延迟,当我意识到你只是 1. 延长动画的持续时间并为每个动画增加时间比例。Beore 我让它们每个持续 0.5 秒,总持续时间为 2.5 秒。现在假设我想添加一个等于总持续时间的延迟,所以延迟 2.5 秒。
You animation time is 2.5 seconds and delay is 2.5, so you change duration to 5 seconds. However, because you doubled the total duration, you'll want to halve the animations proportion. Check the final below. This worked perfectly for me.
您的动画时间为 2.5 秒,延迟为 2.5,因此您将持续时间更改为 5 秒。但是,由于您将总持续时间加倍,您需要将动画比例减半。检查下面的决赛。这对我来说非常有效。
@-webkit-keyframes dance {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
10% {
-webkit-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-o-transform: rotate(20deg);
-ms-transform: rotate(20deg);
transform: rotate(20deg);
}
20% {
-webkit-transform: rotate(-120deg);
-moz-transform: rotate(-120deg);
-o-transform: rotate(-120deg);
-ms-transform: rotate(-120deg);
transform: rotate(-120deg);
}
30% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
40% {
-webkit-transform: rotate(-120deg);
-moz-transform: rotate(-120deg);
-o-transform: rotate(-120deg);
-ms-transform: rotate(-120deg);
transform: rotate(-120deg);
}
50% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
}
In sum:
总共:
These are the calcultions you'd probably use to figure out how to change you animation's duration and the % of each part.
这些是您可能用来确定如何更改动画的持续时间和每个部分的百分比的计算方法。
desired_duration = x
required_duration = x
desired_duration = animation_part_duration1 + animation_part_duration2 + ... (and so on)
required_duration = animation_part_duration1 + animation_part_duration2 + ...(依此类推)
desired_delay = y
期望延迟 = y
total duration = x + y
总持续时间 = x + y
animation_part_duration1_actual = animation_part_duration1 * desired_duration / total_duration
animation_part_duration1_actual = animation_part_duration1 * desired_duration / total_duration
回答by cuth
I would rather write a little JavaScript than make the CSS less manageable.
我宁愿写一点 JavaScript,也不愿让 CSS 更难管理。
First, only apply the CSS animation on a data attribute change:
首先,仅对数据属性更改应用 CSS 动画:
.progbar[data-animation="barshine"] {
animation: barshine 1s linear;
}
Then add javascript to toggle the animation at half the delay amount.
然后添加 javascript 以延迟量的一半切换动画。
var progbar = document.querySelector('.progbar');
var on = false;
setInterval(function () {
progbar.setAttribute('data-animation', (on) ? 'barshine' : '');
on = !on;
}, 3000);
Or if you don't want the animation to run when the tab is hidden:
或者,如果您不希望在选项卡隐藏时运行动画:
var progbar = document.querySelector('.progbar');
var on = false;
var update = function () {
progbar.setAttribute('data-animation', (on) ? 'barshine' : '');
on = !on;
setTimer();
};
var setTimer = function () {
setTimeout(function () {
requestAnimationFrame(update);
}, 3000);
};
setTimer();
回答by Bubas
I made a poster on the wall which moves left and right with intervals. For me it works:
我在墙上做了一张海报,它有间隔地左右移动。对我来说它有效:
.div-animation {
-webkit-animation: bounce 2000ms ease-out;
-moz-animation: bounce 2000ms ease-out;
-o-animation: bounce 2000ms ease-out;
animation: bounce 2000ms ease-out infinite;
-webkit-animation-delay: 2s; /* Chrome, Safari, Opera */
animation-delay: 2s;
transform-origin: 55% 10%;
}
@-webkit-keyframes bounce {
0% {
transform: rotate(0deg);
}
3% {
transform: rotate(1deg);
}
6% {
transform: rotate(2deg);
}
9% {
transform: rotate(3deg);
}
12% {
transform: rotate(2deg);
}
15% {
transform: rotate(1deg);
}
18% {
transform: rotate(0deg);
}
21% {
transform: rotate(-1deg);
}
24% {
transform: rotate(-2deg);
}
27% {
transform: rotate(-3deg);
}
30% {
transform: rotate(-2deg);
}
33% {
transform: rotate(-1deg);
}
36% {
transform: rotate(0deg);
}
100% {
transform: rotate(0deg);
}
}
回答by nolook
Heres a little snippet that shows the same thing for 75% of the time, then it slides. This repeat schema emulates delay nicely:
这是一个小片段,它在 75% 的时间内显示相同的内容,然后滑动。这个重复模式很好地模拟了延迟:
@-webkit-keyframes slide {
0% {background-position: 0 0;}
25% {background-position: 0 0;}
50% {background-position: 0 0;}
75% {background-position: 0 0;}
100% {background-position: 13em 0;}
}
@-moz-keyframes slide {
0% {background-position: 0 0;}
25% {background-position: 0 0;}
50% {background-position: 0 0;}
75% {background-position: 0 0;}
100% {background-position: 13em 0;}
}
@keyframes slide {
0% {background-position: 0 0;}
25% {background-position: 0 0;}
50% {background-position: 0 0;}
75% {background-position: 0 0;}
100% {background-position: 13em 0;}
}
回答by Eric Johnson
Another way you can achieve a pause between animations is to apply a second animation that hides the element for the amount of delay you want. This has the benefit of allowing you to use a CSS easing function like you would normally.
在动画之间实现暂停的另一种方法是应用第二个动画来隐藏元素以获得所需的延迟量。这样做的好处是允许您像平常一样使用 CSS 缓动功能。
.star {
animation: shooting-star 1000ms ease-in-out infinite,
delay-animation 2000ms linear infinite;
}
@keyframes shooting-star {
0% {
transform: translate(0, 0) rotate(45deg);
}
100% {
transform: translate(300px, 300px) rotate(45deg);
}
}
@keyframes delay-animation {
0% {
opacity: 1;
}
50% {
opacity: 1;
}
50.01% {
opacity: 0;
}
100% {
opacity: 0;
}
}
This only works if you want the delay to be a multiple of the animation duration. I used this to make a shower of shooting stars appear more random: https://codepen.io/ericdjohnson/pen/GRpOgVO
这仅在您希望延迟是动画持续时间的倍数时才有效。我用这个让流星雨看起来更随机:https: //codepen.io/ericdjohnson/pen/GRpOgVO
回答by Marcos Silva Lepe
I know this is old but I was looking for the answer in this post and with jquery you can do it easily and without too much hassle. Just declare your animation keyframe in the css and set the class with the atributes you would like. I my case I used the tada animation from css animate:
我知道这是旧的,但我一直在这篇文章中寻找答案,使用 jquery,您可以轻松完成,而不会太麻烦。只需在 css 中声明您的动画关键帧,并使用您想要的属性设置类。我的情况我使用了来自 css animate 的 tada 动画:
.tada {
-webkit-animation-name: tada;
animation-name: tada;
-webkit-animation-duration: 1.25s;
animation-duration: 1.25s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
I wanted the animation to run every 10 seconds so jquery just adds the class, after 6000ms (enough time for the animation to finish) it removes the class and 4 seconds later it adds the class again and so the animation starts again.
我希望动画每 10 秒运行一次,因此 jquery 只需添加类,在 6000 毫秒(动画完成的足够时间)后删除类,4 秒后再次添加类,因此动画再次开始。
$(document).ready(function() {
setInterval(function() {
$(".bottom h2").addClass("tada");//adds the class
setTimeout(function() {//waits 6 seconds to remove the class
$(".bottom h2").removeClass("tada");
}, 6000);
}, 10000)//repeats the process every 10 seconds
});
Not at all difficult like one guy posted.
一点也不像一个人发布的那样困难。
回答by alex067
You can create a "fake" delay between infinite animations purely with CSS. The way to do it is smartly define your keyframe animation points and your animation duration speed.
您可以纯粹使用 CSS 在无限动画之间创建“假”延迟。这样做的方法是巧妙地定义关键帧动画点和动画持续时间。
For example, if we wanted to animate a bouncing ball, and we wanted a good .5s to 1s delay between each bounce, we can do something like:
例如,如果我们想为一个弹跳球设置动画,并且希望每次弹跳之间有 0.5 秒到 1 秒的延迟,我们可以执行以下操作:
@keyframes bounce{
0%{
transform: translateY(0);
}
50%{
transform: translateY(25%);
}
75%{
transform: translateY(15%);
}
90%{
transform: translateY(0%);
}
100%{
transform: translateY(0);
}
}
What we do is make sure that the ball goes back to its original position much earlier than 100%. In my example, I'm doing it in 90% which provided me with around .1s delay which was good enough for me. But obviously for your case, you can either add more key frame points and change the transform values.
我们所做的是确保球比 100% 更早地回到原来的位置。在我的示例中,我以 90% 的速度执行此操作,这为我提供了大约 0.1 秒的延迟,这对我来说已经足够了。但显然对于您的情况,您可以添加更多关键帧点并更改变换值。
Furthermore, you can add additional animation duration to balance your key frame animations.
此外,您可以添加额外的动画持续时间来平衡关键帧动画。
For example:
例如:
animation: bounce .5s ease-in-out infinite;
Lets say that we wanted the full animation to end in .5s, but we wanted an additional .2s in delay between the animations.
假设我们希望完整动画以 0.5 秒结束,但我们希望动画之间有额外的 0.2 秒延迟。
animation: bounce .7s ease-in-out infinite;
So we'll add an additional .2s delay, and in our key frame animations, we can add more percentage points to fill in the gaps of the .2s delay.
因此,我们将添加额外的 0.2 秒延迟,并且在我们的关键帧动画中,我们可以添加更多百分比来填补 0.2 秒延迟的空白。
回答by Ganesh Yadav
Delay is possible only once at the beginning with infinite. in sort delay doesn't work with infinite loop. for that you have to keep keyframes animation blanks example:
延迟在开始时仅可能一次,并且是无限的。排序延迟不适用于无限循环。为此,您必须保留关键帧动画空白示例:
@-webkit-keyframes barshine {
10% {background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8));
}
60% {background: -webkit-linear-gradient(top, #7db9e8 0%,#d32a2d 100%);}
}
it will animate 10% to 60% and wait to complete 40% more. So 40% comes in delay.
它将动画 10% 到 60% 并等待完成 40% 以上。所以 40% 延迟了。