本文介绍了css:悬停旋转元素并保持新位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有(css?)可以在 element:hover 上旋转元素并在移出鼠标时保持新位置吗?

I there a (css?) possibility to rotate an element on element:hover and keep the new position when moving the mouse out?

当光标离开:hover - 区域时,元素似乎会旋转回其默认位置.

It seems that the element rotates back to it`s default position when the cursor leaves the :hover - area.

现在它似乎起作用了(忘了说,我希望它每次/多次发生):

now it seems to work (forgot to say, that i wanted it to happen each time/ multiple times):

var rotate = 360;
  $('.artistbutton360').bind({
    mouseenter: function() {
      $(this).css("-webkit-transform","rotate("+ rotate +"deg)");
      $(this).css("-moz-transform","rotate("+ rotate +"deg)");
      $(this).css("-o-transform","rotate("+ rotate +"deg)");
      $(this).css("transform","rotate("+ rotate +"deg)");
      rotate = rotate + 360;
    }
});

推荐答案

可以使用 jquery:

You can use jquery:

$('element').hover(function(){
  $(this).css(whatever);
});

记得添加

$(document).ready(function(){

});

这篇关于css:悬停旋转元素并保持新位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 17:21