https://jsfiddle.net/eunjin/zasmLkzm/4/jQuery的懸停和線旋轉動畫
$('#menu_bar').hover(function(){
$('.line1').stop().animate({borderSpacing:45},{
step: function(now,fx){
$(this).css('-webkit-transform','rotate('+now+'deg)');
$(this).css('-moz-transform','rotate('+now+'deg)');
$(this).css('transform','rotate('+now+'deg)');
},
duration:'slow'
},'linear');
$('.line3').stop().animate({borderSpacing:-45},{
step: function(now,fx){
$(this).css('-webkit-transform','rotate('+now+'deg)');
$(this).css('-moz-transform','rotate('+now+'deg)');
$(this).css('transform','rotate('+now+'deg)');
},
duration:'slow'
},'linear');
}, function(){
$('.line1').stop().animate({borderSpacing:0},{
step: function(now,fx){
$(this).css('-webkit-transform','rotate('+now+'deg)');
$(this).css('-moz-transform','rotate('+now+'deg)');
$(this).css('transform','rotate('+now+'deg)');
},
duration:'slow'
},'linear');
$('.line3').stop().animate({borderSpacing:0},{
step: function(now,fx){
$(this).css('-webkit-transform','rotate('+now+'deg)');
$(this).css('-moz-transform','rotate('+now+'deg)');
$(this).css('transform','rotate('+now+'deg)');
},
duration:'slow'
},'linear');
});
i顯示了別人的代碼,並使用它,但它不旋轉的 - 代碼 當我鍵入+45,其旋轉懸停和unhover 但-45型它旋轉,懸停,但unhover,它旋轉不平穩
抱歉,我的英語我不使用工程來我的母語
你可以添加這個CSS:'.line1 { transform-origin:50%150%0; }'。一旦你改變了轉換原點,它就會像你期望的那樣工作。這是更新的[小提琴](https://jsfiddle.net/zasmLkzm/7/)。 – sahil
我的問題是.line3,因爲.line1旋轉平穩,但.line3不是TT –