2012-03-21 5 views
1

CSS関数を動的にする方法はありますか?CSSのアニメーション幅を変更することは可能ですか?

.test2 
{ 
    width:200px; 
    height: 90%; 
    -webkit-animation:myfirst2 linear; /* Safari and Chrome */ 
    -webkit-animation-duration: 10s; 
} 

@-webkit-keyframes myfirst2 /* Safari and Chrome */ 
{ 
    from { height: 0%; } <--this must be dynamic 
    to { height: 90%; } <--this must be dynamic 
}  

私はJavaScriptを使用してfrom { height: 0%; }to { height: 90%; }がダイナミックたいです。

これは可能ですか?あなたはイースリーの.cssに与えることができます

http://jsfiddle.net/QrbNW/1/

+0

あなたがこれを行うことができところで – tkone

+1

これはあなたが望むものになりそうだ。http://stackoverflow.com/questions/2495829/dynamically-modify-webkit-animation-with-javascript – callumacrae

+0

はい、おかげでカラム・マクレイ。これは私が探していた解決策でした。 – robind38

答えて

5

あなたはjsfiddle例を持って

$('.foo').css({'-webkit-animation': 'myfirst2 linear', '-webkit-animation-duration': '10s'}); 
0

使用jQueryとjQueryのここでの機能 をアニメーションjQueryのCSS()関数を使用することができます

このように

//Fade in Background 
      jQuery('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeOut(); //Fade in the fade layer  


     //Apply Margin to Popup 
      jQuery('#' + popID).css({ 
       'margin-top' : -popMargTop, 
       'margin-left' : -popMargLeft, 
       'display' : 'block' 
      }); 
0

関連する問題