English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
CSS3 animation-The duration attribute specifies the number of seconds (s) or milliseconds (ms) the animation should take to complete one cycle.
The following table summarizes the usage context and version history of this attribute.
Default Value: | 0s |
---|---|
Applies to: | All elements ::before and ::after Pseudo-element |
Inheritance: | None |
Animated by: | No.Please see Animation Properties. |
Version: | CSS3new feature |
JavaScript Syntax: | object object.style.animationDuration="3s" |
The syntax of this attribute is as follows:
animation-duration: time | initial | inherit
The following example demonstrates how to use animation-duration Attribute.
.box { width: 50px; height: 50px; background: red; position: relative; /* Chrome, Safari, Opera */ -webkit-animation-name: moveit; -webkit-animation-duration: 2s; animation-name: moveit; animation-duration: 2s; } /* Chrome, Safari, Opera */ @-webkit-keyframes moveit { from {left: 0;} to {left: 50%;} } @keyframes moveit { from {left: 0;} to {left: 50%;} }Test and See‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
time | Specify the time required for the animation to complete one cycle. The default value is 0s. Negative values are invalid. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated element adopts its parent element's animation-Calculation Value of duration Attribute. |
animation-Browser Compatibility of duration Attribute, all mainstream browsers support this attribute.
|
Please refer to the following tutorials:CSS3Animation.
Related Properties and Rules:animation,animation-name,animation-duration,animation-timing-function,animation-iteration-count,animation-duration,animation-fill-mode,animation-play-state,@keyframes.