Reputation: 53
I am creating a stop-motion animation of a running cat. I have already all the slides ready. But it doesn't seem to work properly:
div {
animation: run 1s steps(10) infinite;
-webkit-animation: run 1s steps(10) infinite;
background: url(http://stash.rachelnabors.com/img/codepen/tuna_sprite.png) 0 0;
background-repeat: no-repeat;
height: 200px;
width: 400px;
}
@keyframes run {
0% {background-position: 100% 0; }
100% {background-position: 100% -2591px; }
}
@-webkit-keyframes run {
0% {background-position: 100% 0; }
100% {background-position: 100% -2591px; }
}
<div></div>
Upvotes: 5
Views: 1826
Reputation: 5477
Actually you have 13 slides. So put steps(13)
div {
animation: run 1s steps(13) infinite;
-webkit-animation: run 1s steps(13) infinite;
background: url(http://stash.rachelnabors.com/img/codepen/tuna_sprite.png) 0 0;
background-repeat: no-repeat;
height: 200px;
width: 400px;
}
@keyframes run {
0% {background-position: 100% 0; }
100% {background-position: 100% -2591px; }
}
@-webkit-keyframes run {
0% {background-position: 100% 0; }
100% {background-position: 100% -2591px; }
}
<div></div>
Upvotes: 8