2013-03-26 44 views
-1

旋轉一個div我有一個div我要旋轉的mouseenter事件,使用jQuery和CSS2

我想旋轉是動畫不是一招 - 像:hover - ,當然是有jQuery的任何想法,使它??

+2

http://stackoverflow.com/questions/382591/rotating-a-div-element-in-jquery – gaynorvader 2013-03-26 14:20:01

+1

https://developer.mozilla.org/ en-US/docs/CSS/transform – Blazemonger 2013-03-26 14:22:52

+0

我發現了很多可以幫助您使用jQuery旋轉的示例:[https://code.google.com/p/jqueryrotate/wiki/Examples](https://code。 google.com/p/jqueryrotate/wiki/Examples) – Djouuuuh 2013-03-26 14:24:15

回答

1

如果你挖空你的搜索,你會發現很多例子。 例如,來自here我發現這一點:

$(function() { 
    var $elie = $(selectorForElementsToRotate); 
    rotate(0); 
    function rotate(degree) { 

      // For webkit browsers: e.g. Chrome 
     $elie.css({ WebkitTransform: 'rotate(' + degree + 'deg)'}); 
      // For Mozilla browser: e.g. Firefox 
     $elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'}); 

      // Animate rotation with a recursive call 
     setTimeout(function() { rotate(++degree); },5); 
    } 
}); 
+1

來自另一個答案的代碼的另一個副本,在這裏:http://stackoverflow.com/a/3792085/237838 – 2013-04-22 13:51:20