English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
transition-The duration CSS attribute specifies the number of seconds or milliseconds required for the transition animation to complete.
The following table provides usage instructions and version history of this attribute, as well as its usage syntax in JavaScript scripts.
Default value: | 0s |
---|---|
Applicable to: | All elements ::before and ::after Pseudo-element |
Inheritance: | None |
Animatable: | No.Please see Animation properties. |
Version: | CSS3new feature |
JavaScript syntax: | object.style.transitionDuration="5s" |
The syntax of this attribute is as follows:
transition-duration: time | initial | inherit
The following example demonstrates how to use transition-duration attribute.
button { background: #fd7c2a; /* For Safari 3.0+ */ -webkit-transition-property: background; -webkit-transition-duration: 2s; transition-property: background; transition-duration: 2s; } button:hover { background: #3cc16e; }Test and see‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
time | Specify the time required to complete the transition. The default value is 0s. Negative values are invalid. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated element uses its parent element's transition-The value of the duration attribute. |
transition-Browser compatibility of the duration attribute, the numbers in the table below represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.
|
Please refer to the following tutorials:CSS3 Transitions.
Related attributes:transition,transition-delay,transition-property,transition-timing-function.