CSS transitions allows you to change property values smoothly, over a given duration.
Mouse over the element below to see a CSS transition effect:
In this chapter you will learn about the following properties:
transition
transition-delay
transition-duration
transition-property
transition-timing-function
How to Use CSS Transitions?
To create a transition effect, you must specify two things:
Note: If the duration part is not specified, the transition will have no effect, because the default value is 0.
The following example shows a 100px * 100px red <div> element. The <div> element has also specified a transition effect for the width property, with a duration of 2 seconds:
Change Several Property Values
The following example adds a transition effect for both the width and height property, with a duration of 2 seconds for the width and 4 seconds for the height:
The transition-timing-function
property specifies the speed curve of the transition effect.
The transition-timing-function
property can have the following values:
The following example shows some of the different speed curves that can be used:
The following example adds a transition effect to the transformation.
The CSS transition properties can be specified one by one, like this: