Animation settings
Live preview
@keyframes rule.Animation class rule
Apply this to the element you want to move.
Keyframe definition
The steps the animation moves through.
How it works
Keyframe stops
A @keyframes rule is a list of snapshots. Each percentage is a point in time: 0% is the start, 100% is the end, and 50% is halfway through the duration. The browser fills in every frame between the snapshots for you.
from is another name for 0%, and to is another name for 100%. Use them when an animation only needs a start and an end.
Stops that look the same can share one rule, like 0%, 100% { … }. The Bounce and Shake presets use this.
The animation properties
- animation-name
- Which
@keyframesrule to play. It must match the name after@keyframesexactly. - animation-duration
- How long one cycle takes, in seconds (
s) or milliseconds (ms). - animation-timing-function
- The speed curve between stops.
linearis constant speed,ease-instarts slow,ease-outends slow, andcubic-bezier()lets you draw your own curve, including overshoot. - animation-iteration-count
- How many times the cycle repeats.
infinitenever stops. - animation-direction
normalplays 0% → 100%,reverseplays 100% → 0%, andalternategoes forward, then backward, on each repeat.- animation-fill-mode
- What the element looks like before and after it plays.
forwardskeeps the last frame;nonesnaps back to the element’s normal style.
The animation shorthand combines them on one line, in this order: name, duration, timing function, iteration count, direction, fill mode. Turn on Longhand above the code to see each property separately.