0

I have a question on the :hover state. Can I stop my transition from turning back to the original state after stopping the mouseover.

div {
  width:100px;
  height:100px;
  background:red;
  margin: 150px;
  -webkit-transition:all 1s; 
}

div:hover {
  border-radius:50%;
  -webkit-transform:rotate(1440deg);
}

Fiddle

That is what I have, but I don't know what to add to stop the whole thing in circle-state. I just want the :hover pseudo-class to start it.

OrangeDog
  • 36,653
  • 12
  • 122
  • 207
poochy
  • 17
  • 4

1 Answers1

1

You'll need to use JavaScript. Add a class on hover, and set the CSS rules as follows:

element {
    transition: ....;
    old: state;
}

element.hovered-once {
    news: state;
}

The transition will activate when the class get applied, and just don't remove the class when mouse is out.

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308