CSS sprite sheet animation

by glebcha

HTML

<img src="http://s.cdpn.io/79/sprite-steps.png" />
<div class="hi"></div>

CSS

.hi {
    width: 50px;
    height: 72px;
    background-image: url("http://s.cdpn.io/79/sprite-steps.png");
    

            -webkit-animation: play 10s steps(10) infinite;
}
.hi:hover {
	-webkit-animation-play-state: paused;
	animation-play-state: paused;
}

@-webkit-keyframes play {
   0%, 10% { background-position:    0px; }
    10%, 60% { background-position: -500px; }
    90%, 100% { background-position: -500px; }
}

@-moz-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@-ms-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@-o-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

JavaScript

// Sprite Sheet animation with CSS3 using the steps() feature.
// To change the speed, just edit the ".8s" animation time.

// Post: http://simurai.com/blog/2012/12/03/step-animation/

// Inspired by Lea's typing animation: http://t.co/9RPMmV7