CSS Animations
What are Animations?
CSS animations let you create complex, multi-step animations using
@keyframes. Unlike transitions, animations can run
automatically and loop!
Basic Keyframes
Define animation steps with @keyframes, then apply with
animation-name and animation-duration.
Percentage Keyframes
Use percentages for multi-step animations. 0% = start,
100% = end.
Animation Iteration
animation-iteration-count controls how many times the
animation runs. Use infinite for endless loops.
Animation Direction
animation-direction controls playback:
normal, reverse,
alternate, alternate-reverse.
Animation Fill Mode
animation-fill-mode controls styles
before/after animation: none,
forwards, backwards,
both.
Animation Shorthand
Combine all properties:
animation: name duration timing-function delay iteration-count direction fill-mode.
animation-play-state: paused on
hover to pause animations for better UX. Great
for loading spinners!
Summary
@keyframes- Define animation stepsanimation-name- Which keyframe to useanimation-duration- How longanimation-iteration-count- How many timesanimation-direction- Playback directionanimation-fill-mode- Before/after styles- Use
infinitefor endless loops
Quick Quiz
Which value makes an animation loop forever?
Enjoying these tutorials?