我正在旋转div,如下面的代码所示。 问题是我不知道如何使元素从最后一个位置继续时,我再次单击它。我怎么做? (我是能够做到这一点在没有在IE浏览器的方式)使用jQuery旋转,请记住位置
HTML:
<div class="square">click me</div>
CSS:
.square {
background:red;
height:100px;
width:100px;
cursor:pointer;
}
JS:
$('.square').click(function() {
rotate($(this), -180, 1000);
});
function rotate(element, degrees, speed) {
element.animate({
borderSpacing: degrees
}, {
duration: speed,
step: function (now, fx) {
$(this).css('-webkit-transform', 'rotate(' + now + 'deg)');
$(this).css('-moz-transform', 'rotate(' + now + 'deg)');
$(this).css('transform', 'rotate(' + now + 'deg)');
}
});
}
只需使用两种不同类型和交换拨动他们用jQuery。 –
你想要左侧或右侧图像旋转? – Illaya
你是什么意思Paulie_D?我没有问题Illaya – WIRN