How to dynamically create '@-Keyframe' CSS animations?

前端 未结 9 1264
误落风尘
误落风尘 2020-11-27 03:42

I have a requirement to rotate a div and stop at a particular position ( The value will be received from the server).

I tried native JS to rotate and stop but it is

9条回答
  •  一个人的身影
    2020-11-27 04:15

    You could create a new stylesheet with the animation you want in it. For Example:

    function addAnimation(keyframe){
         var ss=document.createElement('style');
         ss.innerText=keyframe;
         document.head.appendChild(ss);
    }
    

    This would create a new stylesheet with your animation.
    This method has only been tested in Chrome.

提交回复
热议问题