CSS transition Property

❮ Previous Reference Next ❯

This example will show longhand transition properties:

Example

div {
  transition-property: width
  transition-duration: 2s
  transition-timing-function: ease-in-out
  transition-delay: 2s
}

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

Example

div {
  transition: width 2s ease-in-out 2s;
}

Example

div {
  width: 100px;
  background: red;
  transition: width 2s;
}

div:hover {
  width: 500px;
}





Hover me!

Meaning

The transition is a shorthand property for:

Default value:all 0s ease 0s
Inherited:No
Animatable:No
Version:CSS3
JavaScript syntax:
object.style.transition="transition-property transition-duration transition-timing-function transition-delay|initial|inherit|revert|revert-layer|unset";



Standard Syntax

transition: transition-property transition-duration transition-timing-function transition-delay|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
transition-property Default value is all. Specifies the name of the CSS property the transition effect is for.
transition-duration Default value is 0s. Specifies how many seconds or milliseconds the transition effect takes to complete.
transition-timing-function Default value is ease. Specifies the speed curve of the transition effect.
transition-delay Default value is 0s. Specifies when the transition effect will start.
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: all 0s ease 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 ❯