Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

rotation - css :hover rotate element and keep the new position

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

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

edit:

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;
    }
});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use jquery:

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

remember adding

$(document).ready(function(){

});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...