CSS3 - 动画延迟不起作用

标签 css css-animations

我这里有一个简单的 CSS3 动画。

#FadeIn3 {
    animation-delay: 20s;
    -webkit-animation-delay: 20s;
    animation: FadeIn 3s;
    -webkit-animation: FadeIn 3s;
}

我想我不必链接动画本身,因为它工作得很好。

另外,HTML 没问题,除了 animation-delay 之外一切正常。

最佳答案

顺序有误,需要下animation-delayanimation 之后这是速记属性,因此它会重置延迟计时器。

animation的顺序速记如下……

enter image description here 顺序在每个动画定义中都很重要:可以解析为 <time> 的第一个值分配给 animation-duration , 第二个分配给 animation-delay .

致谢:Mozilla Developer Network


因此,您在 animation-delay 之后定义它属性(property),因此,animation将延迟重置为 0

Demo (不会工作)

Demo 2 (调换了属性定义的顺序)

Note: I've minimized the timer to 3s delay so that you can see the effect faster.


建议:总是在声明标准属性之前声明带前缀的属性,所以不要这样写

animation-delay: 20s;
-webkit-animation-delay: 20s;

有这样写属性的习惯

-webkit-animation-delay: 20s;
animation-delay: 20s;

关于CSS3 - 动画延迟不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23054067/

相关文章:

internet-explorer - css3 Swing 动画在 IE 中不起作用

css - 突出显示元素然后过渡回原始颜色

html - 扩展表

html - 当我减小窗口大小时,Flex-wrap 没有换行

移动div的CSS渐变背景?

css - 动画在悬停时和悬停时都不起作用

javascript - 如何停止 CSS3 过渡

jquery - 当在文本框中输入文本时,下拉菜单的值应该改变

css - 如何制作矩形(右边有三 Angular 形)边框渐变?

css - 全屏背景 html5 不适用于 google chrome 浏览器