CSS property transition can be used to create animation effect when other specified properties change. This can only be applied on animatable properties.
CSS property transition
CSS version: | CSS 3 |
Value: | single-transition [,single-transition]* |
single-transition: | none | [transition-property || transition-duration || transition-timing-function || transition-delay] |
Initial: | see individual properties |
Applies to: | all elements, :before and :after pseudo elements |
Inherited: | no |
- When transition value is none, multiple transition values cannot be specified.
- The values within single single-transition shorthand should be in order.
Example – transition
Change background-color on hover with transition effect.
In the following code, CSS property transition can be changed to the following values
- background-color 2s ease
- background-color 1s linear
<style type="text/css"> a:hover { background-color: lightblue; } a { transition: background-color 2s ease; } </style> <a href="#link1">Hover me to see transition in background-color</a>
transition refresh
Related
Specification and Browser compatibility
Specification | Status | Categories |
---|---|---|
CSS3 Transitions | W3C Working Draft | CSS3 |
Chrome | Firefox | IE | Edge | Safari | Opera |
---|---|---|---|---|---|
Yes 26+ | Yes 16+ | Yes 10+ | Yes 12+ | Yes 6.1+ | Yes 12.1+ |
Android Chrome | Android Firefox | iOS Safari | IE Mobile | Opera Mobile |
---|---|---|---|---|
Yes 47+ | Yes 44+ | Yes 7.0-7.1+ | Yes 10+ | Yes 12.1+ |
source: caniuse.com