Pause a WebKit animation on hover

user2760221 picture user2760221 · Nov 18, 2013 · Viewed 37.9k times · Source

I'm trying to get an animation to pause on mouse over with the following:

.quote:nth-child(1):hover {
    -webkit-animation-play-state: paused;
    -moz-animation-play-state: paused;
    -o-animation-play-state: paused;
    animation-play-state: paused;
}

But it does not want to pause. Can anybody see what I'm doing wrong?

JSFIDDLE

Answer

tomsullivan1989 picture tomsullivan1989 · Nov 18, 2013

Instead of:

.quote:nth-child(1):hover 
{
    -webkit-animation-play-state: paused;
    -moz-animation-play-state: paused;
    -o-animation-play-state: paused;
    animation-play-state: paused;
}

use:

.quote-wrapper:hover .quote 
{
    -webkit-animation-play-state: paused;
    -moz-animation-play-state: paused;
    -o-animation-play-state: paused;
     animation-play-state: paused;
}

DEMO: http://jsfiddle.net/j4Abq/2/