3

I have the following code:

img:hover {
  -webkit-animation:spin 0.5s linear forwards;
  -moz-animation:spin 0.5s linear forwards;
  animation:spin 0.5s linear forwards;
}

@-moz-keyframes spin {
    100% {
        -moz-transform: rotatey(360deg);
    }
}

@-webkit-keyframse spin {
    100% {
    -webkit-transform: rotatey(360deg);
    }
}
@keyframes spin {
    100% {
        -webkit-transform: rotatey(360deg);
        transform:rotatey(360deg);
    }
}

See live demo here

I have an image that rotates over itself on hover. I want the same effect to happen when hover out.

How to achieve that?

Sonhja
  • 8,230
  • 20
  • 73
  • 131
  • But I don't want it to rotate infinite... if I hover on it, I want it to rotate only once. If I keep my mouse on it while hover, then it will keep rotating, and that's not what I want. – Sonhja Aug 27 '15 at 09:55

1 Answers1

3

Why not use transition instead of animation?

img{
    transform: rotatey(0deg);
    transition: transform .5s ease-in-out;
}
img:hover {
  transform: rotatey(360deg);
}

https://jsfiddle.net/62RJc/342/

m4n0
  • 29,823
  • 27
  • 76
  • 89
Jacob
  • 1,933
  • 2
  • 20
  • 30