【发布时间】:2012-10-07 12:55:33
【问题描述】:
So I've seen a good example on how to rotate a DIV with jQuery and CSS3 manipulation,我现在的问题是,当我试图在 div 上创建一个流畅的悬停效果时,我需要 DIV 将反词转到 -15deg,然后再转到 15deg。
在示例中,我将此效果附加到单击按钮上。
发生的情况是,当您第一次按“bk”时,div 似乎会对齐,然后在您按“fwd”时再次对齐。
我似乎无法弄清楚为什么。
.red
{
width:200px;
position:absolute;
top:50px;
left:50px;
height:200px;
background:red;
-webkit-transform: rotate(10deg);
border-spacing:0px;
}
$('#bk').click(function() {
$('.red').animate({
borderSpacing: -15
}, {
step: function(now, fx) {
$(this).css('-webkit-transform', 'rotate(' + now + 'deg)');
},
duration: 'slow'
}, 'linear');
});
$('#fwd').click(function() {
$('.red').animate({
borderSpacing: 15
}, {
step: function(now, fx) {
$(this).css('-webkit-transform', 'rotate(' + now + 'deg)');
},
duration: 'slow'
}, 'linear');
});
【问题讨论】:
标签: jquery jquery-animate css-transitions