Web4College

CSS transition property

src

Description

CSS transition is a shorthand property of transition-property, transition-duration, transition-timing-function, and transition-delay.


We take an example of a box that rotates by 270 degree on mouse hover within duration of 4s but with different values of transition-delay.

Syntax

transition : none | [ transition-property    transition-duration    transition-timing-function    transition-delay ]

Property values

transition-property

widthDefault

transition starts its execution as soon as it starts.

transition-property: width;
Try it

transition-duration

+ve value (seconds)Default

0

It determnines the duration of transition. transition occurs instantly for 0s.

transition-duration: 0s;
Try it

+ve value (seconds)

2.5

transition-duration also accepts fractional values. Change in the property value occurs within 2.5s.

transition-duration: 2.5s;
Try it

+ve value (milliseconds)

2000

time in milliseconds may also be used as the value. 2000ms means 2s.

transition-duration: 2000ms;
Try it

transition-timing-function

easeDefault

The speed of transition is constant over its duration. It represents normal behavior over the transition-duration.

transition-timing-function: ease;
Try it

ease-in

The speed is slow at the start of transition i.e. It represents somooth behavior at the start only.

transition-timing-function: ease-in;
Try it

ease-out

The speed is fast at the start of transition i.e. The transition is smooth at the end.

transition-timing-function: ease-out;
Try it

ease-in-out

The speed of transition is slow at the start and end of transition-duration as compared to intermediate time. It represents smooth behavior at the start and end of the transition.

transition-timing-function: ease-in-out;
Try it

transition-delay

+ve value (seconds)Default

0

transition-delay accepts value in seconds. 0s means the transition starts its execution as soon as it starts.

transition-delay: 0s;
Try it

+ve value (seconds)

2.5

transition-delay also accepts fractional values. 2.5s means the transition starts execution after 2.5 seconds when it is applied.

transition-delay: 2.5s;
Try it

+ve value (milliseconds)

2000

value in milliseconds may also be used. 2000ms means 2s. Wait for 2000ms to see the execution of transition.

transition-delay: 2000ms;
Try it

-ve value (seconds)

-2

It starts execution partway through its life cycle. If the transition-duration is 3s and transition-delay is -2s, it shows a part of cycle that remains after subtracting transition-delay from transition-duration (1s).

transition-delay: -2s;
Try it

Applicable to

It applies to all elements