CSS animation-duration Property

❮ Previous Reference Next ❯

Example

div {
  animation-duration: 0.5s;
}




Note: 1000ms(milliseconds) is equal to 1s(second)

Meaning

The animation-duration property is used to define the time it takes one iteration of an animation to play.

Default value:0
Inherited:No
Animatable:No
Version:CSS3
JavaScript syntax:
object.style.animationDuration="time|initial|inherit|revert|revert-layer|unset";



Standard Syntax

animation-duration: time|initial|inherit|revert|revert-layer|unset;



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







Property Values

The following table describes the values of this property:

Value Description
time The time that an animation takes to complete one cycle. This may be specified in either seconds (s) or milliseconds (ms). The value must be positive or zero and the unit is required. A value of 0s, which is the default value, indicates that no animation should occur.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.



Default CSS Property Values

selectors {
  animation-duration: 0;
}



More Example

Example

div {
  width: 100px;
  height: 100px;
  background: red;
  position: relative;
  animation-iteration-count: infinite;
  animation-name: demo;
  animation-duration: 2s;
}

@keyframes demo {
  from {left: 0%;}
  to {left: 50%;}
}
❮ Previous Reference Next ❯