transition
Instead of a value’s normal behavior to change immediately it is faded smoothly.
Compatibility
-webkit-transitionSafari 5+transitionFirefox 16+ Chrome 26+ Internet Exlorer 10+ Opera 12.1+
Not supported by Internet Explorer prior to version 10. For detailed compatibility info see caniuse.com.
- Firefox 16+
- Safari 5+
- Chrome 26+
- Internet Explorer 10+
- Opera 12.1+
General description
Combined notation
Multiple transitions can be specified comma separated. There is also the possibility for separated notations.
transition: 1 background-color 2 2s 3 linear 4 0.5s
- 1 The CSS property to be transitioned. Many of the available properties can be animated. Can also be
allif all given properties for an element should be transitioned, for examplebackground-colorandwidthat the same time. If set tononeno transition is executed. - 2 The transition lasts
2seconds (the duration). Defaults to0meaning that there is no transition at all (like the normal behavior of a status change). Negative values are not allowed. - 3 Optional. The timing-function, which describes how the transition will proceed over its duration. It is specified using a bezier curve (and can also be set as one). At the given example the animation is played
linearwithout an acceleration or a slowdown. Defaults toeasewhich results in a fast beginning and a slowdown at the end.ease-outis quite the same but not so fast at the beginning.ease-inaccelerates the animation smoothly at the beginning with no slowdown at the end. At lastease-in-outstands for an acceleration at the beginning and a slowdown at the end.
There is also the possibility of step-values, which let the animation jump between the individual keyframes, wherebystep-startomits the first keyframe andstep-endthe last one.steps(X, start/end)in turn enables to define how many steps are shown between each keyframe, whereXstands for the steps andstart/enddefines if the first or the last keyframe should be omitted (defaults toendif omitted). - 4 Optional. The transition starts with a delay of
0.5seconds. If not set or set to0it will begin immediately, if negative it will begin part-way through its play cycle.
Separated notations
Results in the same transition like above.
transition-property: background-color
transition-duration: 2s
transition-timing-function: linear
transition-delay: 0.5s
Example
Multiple transitions set
transition: 1 width 3s, 2 opacity 2s 3s ease-in
- 1 The
widthof the element is transitioned over a period of3seconds. Sincetransition-durationandtransition-timing-functionare absent the animation starts immediately with a acceleration at the beginning and a slowdown at the end (ease, standard value). - 2 The transition of the element’s
opacitylasts2seconds and starts after3seconds. That is, that the animation of theopacitystarts not until the animation of thewidthis already over. At last it has smooth acceleration at the beginning and no slowdown at the end (ease-in).
Further reading
For more info see the W3C site, the Safari site and the site at MDN (including compatibility info for older browser versions).

