3

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";

なぜ?

ライブプレビュー(忍者スターをクリック)

4

1 に答える 1

6

そのアニメーションを使用して別のクラスを作成し、必要に応じて要素にアタッチすることをお勧めします。

anim_logo.setAttribute("class", yourAnimationClass);

アップデート

新しく追加されたクラスを削除するには、delayed関数を使用できます。

function animateMe() {
    anim_logo.setAttribute( "class", yourAnimationClass );
    setTimeout( function() {
        anim_logo.setAttribute( "class", "" );
    }, 3000);
}
于 2012-10-12T20:14:35.630 に答える