如何使用js启动CSS动画?第一行(webkitAnimation)可以工作,但其他行不能。
anim_logo.style.webkitAnimation="threesixty 3s";
anim_logo.style.mozAnimation="threesixty 3s";
anim_logo.style.oAnimation="threesixty 3s";
anim_logo.style.animation="threesixty 3s";为什么?
live preview (点击忍者之星)
发布于 2012-10-13 04:14:36
您最好使用该动画创建一个单独的类,并在需要时简单地将其附加到您的元素:
anim_logo.setAttribute("class", yourAnimationClass);更新
要删除新添加的类,可以使用延迟函数:
function animateMe() {
anim_logo.setAttribute( "class", yourAnimationClass );
setTimeout( function() {
anim_logo.setAttribute( "class", "" );
}, 3000);
}https://stackoverflow.com/questions/12866385
复制相似问题