I am trying to get this animation to stay in its last keyframe on hover but it keeps reverting back to the beginning. I don't mind if I hover off it reverts but not during the hover. I looked through a lot of stack questions and everyone said to uses the animation-fill-mode: forwards, but that doesn't seem to work.
Here is my code and a link to a jsfiddle
.circle:hover .spin {
-webkit-animation-name: drop;
-webkit-animation-duration: 1s;
-webkit-animation-iteration-count: 1;
-webkit-animation-direction: alternate;
-webkit-animation-timing-function: ease-out;
-webkit-animation-delay: 0;
-webkit-animation-fill-mode: forwards;
}
@-webkit-keyframes drop {
100% {
-webkit-transform: rotate(90deg);
}
}
For those of you with a similar problem, first make sure you are using
animation-fill-mode: forwards
. See this related question.In this specific case, the following is relevant:
Since the
.circle
element is aspan
, it isinline
by default, therefore the propertytransform: rotate()
won't have an effect on it after the animation ends. Changing thedisplay
of it to eitherinline-block
orblock
will solve the problem.You should also be using the animation shorthand. In addition, add in other vendor prefixes:
Updated Example Here