javascript - 通过 JS 调用时,CSS3 动画在 Chrome 中不起作用

标签 javascript html css webkit

我有一个带有以下 CSS 的页脚:-

#transFooter {
opacity: 0;
margin-left: -2000px;
}

@-webkit-keyframes transFooter {
    100% { margin-left: 0; opacity: 1; }
}

@keyframes transFooter {
    100% { margin-left: 0; opacity: 1; }
}

它使用以下代码进行动画处理:-

document.getElementById("transFooter").style.animation = "transFooter 2s forwards";

但是,它似乎不适用于 Chrome。有什么想法吗?

最佳答案

在 JavaScript 中,添加:

document.getElementById("transFooter").style["-webkit-animation"] = "transFooter 2s forwards";

http://jsfiddle.net/GMb3C/

关于javascript - 通过 JS 调用时,CSS3 动画在 Chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21179822/

相关文章:

javascript - 将 JavaScript 语句括在括号中有什么意义?

javascript - 当 document.hidden 为 true 时,Chrome 中不会触发滚动事件。任何解决方法?

javascript - React JS 事件未触发最后呈现的元素

javascript - 发送 json 以查看但显示为字符串

html - 如何在 div 的中心左对齐文本?

html - 以 HTML5 格式嵌入 Vimeo 视频的好方法是什么?

css - 更改 <a> 链接下划线颜色

javascript - 菜单图标动画 jQuery

javascript - 将内部 div 移动到外部父 div 的右下角

java - 在 jsoup 中获取 div 类中的文本