循环自动旋转图像

时间:2012-12-28 18:08:03

标签: jquery css3

我想像加载器动画GIF一样旋转图像。

我在html中有<img>标记,我的Jquery代码是这样的:

setInterval(
    function () {
        $('#at_ex1').animate({rotate: '+=10deg'}, 0);
    },
    200
);

但是工作不正常。如何在循环中的Jquery和CSS3中使用此方法。

3 个答案:

答案 0 :(得分:2)

看看这个小提琴,我怀疑它完全符合你的目的。

http://code.google.com/p/jqueryrotate/wiki/Examples

答案 1 :(得分:0)

var $ elie = $(&#34; img&#34;),degree = 0,timer;

function rotate() {

    $elie.css({ WebkitTransform: 'rotate(' + degree + 'deg)'});
    $elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'});
    timer = setTimeout(function() {
        ++degree; rotate();
    },100);
}

答案 2 :(得分:-2)

Baixe o jqueryrotate e insira na head

<script type="text/javascript" src="motor/jQueryRotate.js"></script>

depois no seu js:

var i=1;
var rotacao=setInterval(function(){
$("#imgRotacao").rotate(i);
i++;},10);
相关问题