Basic Declaration & Usage👽
You can use any number of “stops” in the @keyframe animation, and it’s one of the main strengths of keyframe animations. While CSS transition is only from one state to another, a keyframe animation can interpolate between many different states during its timeline.
If an animation has the same starting and ending properties, one way to do that is to comma-separate the 0% and 100% values:
Or, you could always tell the animation to run twice (or any even number of times) and tell the direction to alternate. Calling keyframe animation with separate properties
Calling keyframe animation with separate properties😊💟
Animation Shorthand💓
Just space-separate all the individual values. The order doesn’t matter except when using both duration and delay, they need to be in that order. In the example below 1s = duration, 2s = delay, 3 = iterations.
Multiple animations💕😔😉
You can comma-separate the values to declare multiple animations on a selector.
steps()
The steps() function controls exactly how many keyframes will render in the animation timeframe. Let’s say you declare:
If you use steps(10) in your animation, it will make sure only 10 keyframes happen in the allotted time.
The math works out nicely there. Every one second, the element will move 10px to the left and 10px down, until the end of the animation, and then again in reverse forever.
This can be great for sprite-sheet animation like this demo by samurai.
No comments:
Post a Comment