css - 有人可以告诉我为什么 20 秒延迟在这里不起作用吗?

标签 css

谁能告诉我为什么 20 秒延迟在这里不起作用?

它实际上显示动画 20 秒然后重新开始!

谢谢。

CSS

#birds2 {
    position: absolute;
    left: 0px;
    top: 0px;
    width: 470px;
    height: 93px;
    opacity: 1.0;
    -webkit-animation: birds2_anim 120s linear normal;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-direction: normal, horizontal ;
    -webkit-animation-timing-function: linear, ease-in;
    -webkit-animation-delay:20s;
}   
@-webkit-keyframes birds2_anim {
    0%   { -webkit-transform: translate(500px, 150px); }
    100% { -webkit-transform: translate(-700px, -100px); }
}

Javascript

var container7 = document.getElementById("birdsContainer");
container7.appendChild(createCbird());
function createCbird() {
var image = document.createElement("img");
image.id = "birds2";    
image.src = "Images/Weather/birds/birds1.gif";
return image;

最佳答案

您的延迟/持续时间都很好,但您可能正在寻找这些属性:

-webkit-animation-fill-mode: forwards;
-webkit-animation-iteration-count: 1;

第一个将动画结束设置为最后一帧(默认为第一帧),而第二个使其仅运行一次。

编辑

如果您希望它位于动画的第一帧,请添加

#birds2 {
    left: 500px;
    top: 150px;    
}

@-webkit-keyframes birds2_anim {
    0%   { -webkit-transform: translate(0px, 0px); }      /* Set 0px and 0px */
    /* Or you can simply remove the property, leaving empty brackets for 0% */
    100% { -webkit-transform: translate(-700px, -100px); }
}

Edited Fiddle

关于css - 有人可以告诉我为什么 20 秒延迟在这里不起作用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16397824/

相关文章:

CSS网格和指定多个区域

html - 输入框分离 css 在 ff 和 chrome 中不同

javascript - Angular 4 | Material 2 - 按钮切换组的突出显示未以编程方式正确更改

javascript - 移动到网页的第一个 'default' 焦点

html - 如何在 Office365 的 OWA 任务 Pane 中换行文本

javascript - 如何使用 jQuery 或 Javascript 上传图片

asp.net - 当 id 引用时,CSS 未应用于基页元素

html - 使用 CSS 根据屏幕大小制作一个 HTML 表格的元素是方形的?

javascript - 收集 div 并对其执行 CSS : HTMLCollection vs Array

html - 上传到服务器后出现问题