CSS Reference ยท Transforms, Transitions and Animations
The transition-timing-function property
Reference for the CSS transition-timing-function property: ease, linear, cubic-bezier(), steps() and linear() easing curves, with syntax and live examples.
The transition-timing-function property sets the speed curve of a transition: how the progress between the old and the new value is spread over the duration. A transition can start slowly and finish fast, move at a constant speed, jump in discrete steps, or even overshoot and bounce.
The same easing functions are used by animation-timing-function, the Web Animations API and the animation-timing-function declarations inside keyframes.
.panel { transition: transform 400ms; transition-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
Try it
The last curve uses y-values below 0 and above 1, so the dot pulls back first and then overshoots the end before settling.
Syntax
transition-timing-function: <easing-function># <easing-function> = linear | ease | ease-in | ease-out | ease-in-out | cubic-bezier(<x1>, <y1>, <x2>, <y2>) | steps(<integer>[, <step-position>]) | step-start | step-end | linear(<stop>#)
- Initial value:
ease - Applies to: all elements, and the
::beforeand::afterpseudo-elements - Inherited: no
- Animatable: no
- Computed value: as specified
Values
| Value | Description |
|---|---|
ease |
Starts slowly, speeds up, then slows down at the end. Equal to cubic-bezier(0.25, 0.1, 0.25, 1). |
linear |
A constant speed from start to end. |
ease-in |
Slow start, fast finish: cubic-bezier(0.42, 0, 1, 1). |
ease-out |
Fast start, slow finish: cubic-bezier(0, 0, 0.58, 1). |
ease-in-out |
Slow start and slow end: cubic-bezier(0.42, 0, 0.58, 1). |
cubic-bezier(x1, y1, x2, y2) |
A custom curve. The x values must be between 0 and 1; the y values may go outside that range for overshoot. |
steps(n, position) |
Jumps in n equal steps. The position is jump-start, jump-end (default), jump-both, jump-none, or the older start and end. |
step-start / step-end |
Shortcuts for steps(1, jump-start) and steps(1, jump-end). |
linear(...) |
A piecewise-linear curve built from a list of points, useful for bounces and springs. |
Usage notes
- Pick by purpose.
ease-outsuits things that enter (they arrive quickly and settle),ease-insuits things that leave, andease-in-outsuits movement between two places on screen. linearlooks mechanical for motion, but is the right choice for progress bars, color fades and looping spinners.- Overshoot. A
cubic-bezier()y-value outside 0 to 1 pushes the animated value past its target. That is harmless fortransform, but can produce invalid results for properties that do not accept out-of-range values (for example an opacity above 1 is clamped). steps()for sprites and typewriters. It produces frame-by-frame effects, such as walking through a sprite sheet.linear()is newer. It is part of the modern easing syntax; check a compatibility table before relying on it, and give a fallbackcubic-bezier()declaration first.- Multiple transitions. A list lines up with
transition-propertyentry by entry, so different properties can have different curves. - Browser dev tools include a curve editor for
cubic-bezier()values, which is the easiest way to tune them.
Browser support
The keywords, cubic-bezier() and steps() work in every browser. The linear() function is newer; check a compatibility table.
Related
transitionโ the shorthandtransition-durationโ how long it takesanimation-timing-functionโ easing for keyframe animations- Lesson: Transitions