Driving motion with @keyframes
CSS animations interpolate an element between waypoints defined in a @keyframes
rule, controlled by the animation-* family of properties. This reference lists each
longhand, the animation shorthand and @keyframes itself, with accepted values,
initial values and the behaviour worth remembering.
How it works
You define waypoints in @keyframes name { from { … } to { … } } or with percentage
stops, then attach them with animation-name and a non-zero animation-duration.
The remaining longhands shape playback: timing-function sets the easing between
keyframes, iteration-count and direction control repetition and bounce,
delay offsets the start (negative delays seek into the animation), and fill-mode
decides whether the start or end keyframe persists outside the active window.
The animation shorthand packs these together; its only strict rule is that the
first <time> is the duration and the second is the delay. Newer properties
animation-timeline and animation-range replace the clock with scroll progress for
scroll-driven effects. Filter the list above to find any property fast.
Tips and accessibility
- Always provide both a
nameand a non-zeroduration; withduration: 0snothing visibly animates. - Use
fill-mode: forwardswhen an element should stay in its final state instead of snapping back to its unanimated styles. - Wrap motion in
@media (prefers-reduced-motion: reduce)and tone it down or remove it, so users who are sensitive to motion are respected. !importantdeclarations inside@keyframesare ignored by spec, so do not rely on them to win specificity battles.