Transitions and animations
Change a control, or edit the CSS. The preview uses that same CSS.
Play moved the token with the duration and easing in the CSS. Linear kept a steady speed, and ease-in-out slowed the start and the end. The token traveled the same distance each time. Only the timing changed.
+Go deeper
Only some properties ease
A transition watches a property and eases it when the value changes. Transform and opacity are the cheap ones. Width, height, and anything that changes the of the neighbors can force the page to lay out again on every frame. Prefer transform for a move.
Duration is how long
The time is in milliseconds in the playground and in the declaration: 600ms is a bit over half a second. A very short duration feels like a snap. A very long one feels stuck. The distance of the move stays in the transform. Duration does not change how far it goes.
Easing is the shape
linear keeps a constant speed. ease starts and ends a little softer. ease-in starts slow. ease-out ends slow. ease-in-out does both. The same 180px move feels different because the speed along the way changed.
| Name | Speed | When it feels right |
|---|---|---|
| linear | Constant | A progress meter or a continuous slide |
| ease | Soft ends | A small interface change |
| ease-in | Slow start | Something leaving |
| ease-out | Slow end | Something arriving |
| ease-in-out | Slow at both ends | A longer move |
Replay the same change
The button adds and removes a class that changes transform. The transition declaration does the easing. A transition only runs when something else changes the property, such as that class or a hover. An animation runs by itself: @keyframes names the steps, and the animation property plays them, including a count of infinite. The playground is the transition, so you can feel the easing. If you edit the duration in the CSS and the number is not one of the slider stops, the control shows a custom value and the next replay still uses your number.
Reduced motion is a query
A can ask for prefers-reduced-motion. Inside it, set a near-zero duration or remove the transition. The person asked the page to be still. The playground already does this when the system setting is on.
Guided challenge
Transitions and animations
The declaration says 600ms. The script logs 200ms. Read the duration from the style attribute.
Your console output appears here.
EXPECTED CONSOLE OUTPUT
600ms ease Go
Hints 0/2
Use all hints or make 3 failed runs (0/3).
Free sandbox
Edit the HTML and CSS. The JavaScript tab can read the result. This draft is saved separately.
Your console output appears here.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 200 XP. You can always revisit it.