启动CSS动画的JavaScript [英] Start CSS Animations JavaScript
本文介绍了启动CSS动画的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何开始与JS CSS动画?
第一行(webkitAnimation)的作品,但其他的人则没有。
How can I start CSS animations with js? the first line (webkitAnimation) works but the other ones don't.
anim_logo.style.webkitAnimation="threesixty 3s";
anim_logo.style.mozAnimation="threesixty 3s";
anim_logo.style.oAnimation="threesixty 3s";
anim_logo.style.animation="threesixty 3s";
为什么?
现场preVIEW (点击忍者星)
推荐答案
您最好做一个单独的类与动画,简单地将其连接到你的元素需要的时候:
You better make a separate class with that animation and simply attach it to your element when needed:
anim_logo.setAttribute("class", yourAnimationClass);
更新
要删除新添加的类,你可以使用延迟功能:
To remove the newly added class you can use a delayed function:
function animateMe() {
anim_logo.setAttribute( "class", yourAnimationClass );
setTimeout( function() {
anim_logo.setAttribute( "class", "" );
}, 3000);
}
这篇关于启动CSS动画的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文