您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使用jquery.animate()的CSS旋转跨浏览器

使用jquery.animate()的CSS旋转跨浏览器

CSS转换尚无法与jQuery动画化。您可以执行以下操作:

function AnimateRotate(angle) {
    // caching the object for performance reasons
    var $elem = $('#MyDiv2');

    // we use a pseudo object for the animation
    // (starts from `0` to `angle`), you can name it as you want
    $({deg: 0}).animate({deg: angle}, {
        duration: 2000,
        step: function(Now) {
            // in the step-callback (that is fired each step of the animation),
            // you can use the `Now` paramter which contains the current
            // animation-position (`0` up to `angle`)
            $elem.css({
                transform: 'rotate(' + Now + 'deg)'
            });
        }
    });
}

而且,顺便说一句:您不需要在jQuery 1.7+之前为CSS3转换添加前缀

CSS 2022/1/1 18:21:41 有493人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶