Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style transition property

Style transition property

Style Object Reference The Style object

Example

When you hover the mouse pointer over a div element, its appearance will gradually change:

document.getElementById("myDIV").style.transition="all 2s";

Try it »


Definition and Usage

The transition property is a shorthand property used to set four transition properties:

transitionProperty, transitionDuration, transitionTimingFunction and transitionDelay.

**Note:** Always set the transitionDuration property, otherwise the duration will be 0 and no transition effect will occur.


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

Internet Explorer 10, Firefox, Opera and Chrome support the transition property.

Safari supports another property that can replace this property, namely the WebkitTransition property.

**Note:** Internet Explorer 9 and earlier versions do not support the transition property.

Syntax

Return the transition property:

object

.style.transition

Set the transition property:

object

.style.transition="

property duration timing-function delay

|initial|inherit"

Attribute values

Value Description
transitionProperty Specifies the name of the CSS property to which the transition effect applies.
transitionDuration Specifies how many seconds or milliseconds it takes to complete the transition effect.
transitionTimingFunction Specifies the speed curve of the transition effect.
transitionDelay Defines when the transition effect starts.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default value: all 0 ease 0
Return Value: A string, representing the transition property of an element.
CSS version CSS3

Related Articles

CSS Reference Manual:transition property


Style Object Reference The Style object