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

CSS3 transition-timing-function Property

CSS3 transition-timing-function Property

Example

The transition runs from start to end at a constant speed:

transition-timing-function: linear;

-webkit-transition-timing-function: linear; /* Safari and Chrome */

Try it »


Browser support

The numbers in the table indicate the first browser version that supports this property.

A number immediately before -webkit-, -ms-, or -moz- indicates the first browser version that supports that prefixed property.

property
transition-timing-function 26.0
4.0 -webkit- 10.0 16.0
4.0 -moz- 6.1
3.1 -webkit- 12.1
10.5 -o-

Property definition and usage

transition-timing-function is a CSS3 property used to specify the timing function of a transition. It defines how the transition progresses over time, controlling the speed curve and thus the animation from start to finish.

The value can be one of the following predefined timing functions:

For example, if you want a transition that accelerates slowly and then decelerates slowly, you can write:


.element {
  transition-timing-function: ease;

}

If you want a transition with constant speed, you can write:


.element {
  transition-timing-function: linear;
}

You can also use a custom Bezier curve function for finer control. For example:

.element {
  transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}

This creates a custom slow-in and slow-out effect. You can adjust the four values to change the shape of the curve for a specific transition.

By adjusting the transition-timing-function property, you can control the speed and animation of transitions, making your interface interactions more lively and appealing.

Default value: ease
Inherited: no
Version: CSS3
JavaScript syntax: object.style.transitionTimingFunction="linear"

Syntax

transition-timing-function: linear|ease|ease-in|ease-out|ease-in-out|cubic-bezier(

n

,

n

,

n

,

n

);

Value Description
linear Specifies a transition from start to end at the same speed (equal to cubic-bezier(0,0,1,1)).
ease Specifies a transition that starts slowly, speeds up, then ends slowly (cubic-bezier(0.25,0.1,0.25,1)).
ease-in Specifies a transition that starts slowly (equal to cubic-bezier(0.42,0,1,1)).
ease-out Specifies a transition that ends slowly (equal to cubic-bezier(0,0,0.58,1)).
ease-in-out Specifies a transition that starts and ends slowly (equal to cubic-bezier(0.42,0,0.58,1)).
cubic-bezier(n,n,n,n) Define your own values in the cubic-bezier function. Possible values are numbers between 0 and 1.

More examples

Example

To better understand the different function values: here are five different div elements with five different values:

#div1 {transition-timing-function: linear;}

#div2 {transition-timing-function: ease;}

#div3 {transition-timing-function: ease-in;}

#div4 {transition-timing-function: ease-out;}

#div5 {transition-timing-function: ease-in-out;}

/* Safari */

#div1 {-webkit-transition-timing-function: linear;}

#div2 {-webkit-transition-timing-function: ease;}

#div3 {-webkit-transition-timing-function: ease-in;}

#div4 {-webkit-transition-timing-function: ease-out;}

#div5 {-webkit-transition-timing-function: ease-in-out;}

Try it »

Example

Same as the example above, but specifying the speed curve with a cubic Bezier function:

#div1 {transition-timing-function: cubic-bezier(0,0,1,1;}

#div2 {transition-timing-function: cubic-bezier(0.25,0.1,0.25,1);}

#div3 {transition-timing-function: cubic-bezier(0.42,0,1,1);}

#div4 {transition-timing-function: cubic-bezier(0,0,0.58,1);}

#div5 {transition-timing-function: cubic-bezier(0.42,0,0.58,1);}

/* Safari */

#div1 {-webkit-transition-timing-function: cubic-bezier(0,0,1,1;}

#div2 {-webkit-transition-timing-function: cubic-bezier(0.25,0.1,0.25,1);}

#div3 {-webkit-transition-timing-function: cubic-bezier(0.42,0,1,1);}

#div4 {-webkit-transition-timing-function: cubic-bezier(0,0,0.58,1);}

#div5 {-webkit-transition-timing-function: cubic-bezier(0.42,0,0.58,1);}

Try it »