English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS reference manual

CSS @rules

CSS attribute大全

CSS3 Usage and examples of transition properties

The transition CSS property allows you to define the transition effect between two states of an element. This istransition-property,transition-duration,transition-timing-functionAndtransition-delayAbbreviated property

The following table provides usage instructions and version history for this property, as well as the syntax for using this property in JavaScript scripts.

Default value:all 0 ease 0; View all properties
Applies to:All elements ::before and ::after Pseudo-element
Inheritance:None
Animated production:No.Please refer to Animation Properties.
Version: CSS3new feature
JavaScript Syntax:object.style.transition="width 2s"

The syntax of transition usage

The syntax of this attribute is as follows:

transition: transition1 ,[ transition2,…transitionN] | initial | inherit
            where transition is: [ transition-property | transition-duration | transition-timing-function | transition-delay ]

The following example demonstrates how to use the transition attribute.

button {
    background: #fd7c2a;
    -webkit-transition-property: background 2s; /* For Safari 3.0+ */
    transition: background 2s; 
}
button:hover {
    background: #3cc16e;
}
Test See‹/›

Attribute Value

The following table describes the value of this attribute.

ValueDescription
transition-propertySpecify the name of the CSS properties to which the transition effect should be applied.
transition-durationSpecify the number of seconds or milliseconds required for the transition animation to complete.
transition-timing-functionSpecify how to calculate the intermediate value of the CSS properties affected by the transition.
transition-delaySpecify when the transition should start.
initialSet this attribute to its default value.
inheritIf specified, the associated elements will adopt the attribute value of the parent element's transition.

Browser Compatibility

The compatibility of the transition attribute in browsers, the numbers in the following table represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.

  • Firefox 4+ -moz-,16 +

  • Google Chrome 4+ -webkit-,26 +

  • Internet Explorer 10+

  • Apple Safari 3.1+ -webkit-,6.1+

  • Opera 10.5+ -o-,12.1+

For further reading

Please refer to the following tutorials:CSS3 Transitions.

Related Attributes:transition-delay,transition-duration,transition-property,transition-timing-function.