CSS3 transition
With CSS3, we can add an effect to an element when the element is transformed from one style to another without using Flash animation or JavaScript.
Transition properties
Properties |
Description |
CSS |
Transition |
Shorthand property, which is used to set four transition properties in one property. |
3 |
Transition-property |
Specifies the name of the CSS property that the transition is applied to. |
3 |
Transition-duration |
Defines the time that the transition effect takes. The default is 0. |
3 |
Transition-timing-function |
A time curve that specifies the transition effect. The default is "ease". |
3 |
Transition-delay |
Specifies when the transition effect begins. The default is 0. |
3 |
The following example sets all the transition properties:
Instance
Use all of the transition properties in one example:
div{transition-property:width;transition-duration:1s;transition-timing-function:linear;transition-delay:2s;/* Firefox 4 */-moz-transition-property:width;-moz-transition-duration:1s;-moz-transition-timing-function:linear;- moz-transition-delay:2s;/* Safari and Chrome */-webkit-transition-property:width;-webkit-transition-duration:1s;- webkit-transition-timing-function:linear;-webkit-transition-delay:2s;/* Opera */-o-transition-property:width;-o- Transition-duration:1s;-o-transition-timing-function:linear;-o-transition-delay:2s;}
Abbreviated instance of Transition instances
The transition effect is the same as the example above, but uses the shorthand transition property:
div{transition:width 1s linear 2s;/* Firefox 4 * *
-moz-transition:width 1s linear 2s;/* Safari and Chrome * *
-webkit-transition:width 1s linear 2s;/* Opera * *
-o-transition:width 1s linear 2s;
}
CSS3 Learning Summary 9--CSS3 Transition