CSS transition-duration Property

❮ Previous Reference Next ❯

Example

div {
  transition-duration: 2s;
}





Hover me!

Meaning

The transition-duration property sets the length of time a transition animation should take to complete.

Note: By default, the value is 0s, meaning that no animation will occur.

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



Standard Syntax

transition-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 Default value is 0s. Specifies how many seconds or milliseconds a transition effect takes to complete.
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 {
  transition-duration: 0s;
}



More Examples

The following example show how to set all transition properties using shorthand property:

Example

div {
  width: 100px;
  height: 100px;
  background: red;
  transition: width 2s ease-in-out 2s;
}



The following element combines transitions for: border, width, height, background-color, transform. Hover over the red div element to see these properties animated.

Hover me!

Example

div {
  border: 1px solid;
  width: 100px;
  height: 100px;
  background-color: red;
  transition: border 5s, width 2s, height 2s, background-color 2s, transform 2s;
}

div:hover {
  border: 10px solid;
  background-color: #0069FF;
  width: 200px;
  height: 200px;
  transform: rotate(180deg);
}
❮ Previous Reference Next ❯