0

I am trying to animate a logo with spritesheet ans it is working pretty well. The code is like

#logo {
  background: url('../img/logo.png');
  height: 142px;
  width: 426px;
}
#logo:hover{
  -webkit-animation: logoAnim .2s steps(19) forwards; 
} 
@-webkit-keyframes logoAnim { 
    100% { background-position: -8094px 0; }
}

So the image is animating on mouse hover. Now I am clueless how to reverse the animation on mouse out. Can someone help me pls

Jagadeesh J
  • 1,211
  • 3
  • 11
  • 16
  • possible duplicate of [CSS3: reverse animation on mouse out after hover](http://stackoverflow.com/questions/16516793/css3-reverse-animation-on-mouse-out-after-hover) – Mr. Alien Jan 04 '14 at 11:22

2 Answers2

1

You can achieve the desired effect very easily using jquery like this:

$('#logo').mouseenter(function() {
  $(this).css("background-position","-8094px 0");
});

$('#logo').mouseout(function() {
  $(this).css("background-position","0 0");
});

and you can include the following Css to #logo according to your needs:

#logo {
  -webkit-transition: 200ms ease-in-out;
}
Stefanos Vakirtzis
  • 448
  • 1
  • 7
  • 19
0

This trick is made by animation-direction.

Example:

-webkit-animation: logoAnim 1s alternate-reverse;

http://jsfiddle.net/XuSXK/