2015-01-08 17 views
5

Sto creando un'animazione stop-motion di un gatto in esecuzione. Ho già tutte le diapositive pronte. Ma non sembra funzionare correttamente:Stop Motion Animation CSS

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>

+0

Ecco la spiegazione su come fare questo. [link] (http://24ways.org/2012/flashless-animation/) –

risposta

8

In realtà si hanno 13 diapositive. Così si può mettere 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>

+0

immagine ospitata ha quattro tipi di diapositive come faccio a cambiare lo stile lì (cat running style) intendo immagine marging –

+0

È tutto un gioco di ' background-position'. In '@ keyframes', cambia la coordinata' x' di 'background-position' –

+3

Dovrai regolare l'altezza e no. di passaggi allo stesso modo. –