2015-01-08 15 views
5

Ich erstelle eine Stop-Motion-Animation einer laufenden Katze. Ich habe schon alle Folien fertig. Aber es scheint nicht richtig zu funktionieren: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

Hier ist die Erklärung, wie dies zu tun. [link] (http://24ways.org/2012/flashless-animation/) –

Antwort

8

Eigentlich haben Sie 13 Dias. So setzen 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

gehostetes Bild hat vier Arten von Dia-Aufnahmen, wie ändere ich dort Stil (Katze running style) ich meine Bild marging –

+0

Es ist alles ein Spiel von ' Hintergrund-Position. Ändern Sie in '@ keyframes' die' x' Koordinate der 'background-position'. –

+3

Sie müssen die Höhe und die Anzahl anpassen. Schritte ähnlich. –