CSS3 transition-timing-function Property


Example

Transition effect moves at the same speed from start to end:

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

Try it Yourself »

Browser Support

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

The number immediately before -webkit-, -ms-, or -moz- is the first browser version number that supports the 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 Instructions

transition-timing-function is a CSS3 property used to specify the timing function of a transition effect. It defines how the transition effect changes over time and controls the speed curve of the transition, thereby affecting the animation effect during the element's transition from start to end.

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

  • ease: Default value, a transition effect that accelerates slowly and then decelerates slowly.
  • linear: Uniform transition effect.
  • ease-in: Slowly accelerating transition effect.
  • ease-out: Slowly decelerating transition effect.
  • ease-in-out: A transition effect that first accelerates slowly and then decelerates slowly.
  • cubic-bezier(n,n,n,n): A custom Bezier curve function, which defines the control points of the curve through four values, corresponding respectively tox1、y1、x2、y2。

For example, if you want the transition effect to have a slow acceleration and then a slow deceleration, you can write it like this:

.element {
  transition-timing-function: ease;
<p>}
If you want a uniform transition effect, you can write it like this:
.element {
  transition-timing-function: linear;
}

You can also use a custom Bezier curve function to achieve more refined transition effects. For example:

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

This creates a custom effect of slow acceleration and slow deceleration. You can adjust the four values to adjust the shape of the curve to achieve a specific transition effect.

By adjusting the transition-timing-function property, you can control the speed and animation effect of the transition, making your interface interaction more vivid and engaging.

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 effect that moves at the same speed from start to end (equivalent to cubic-bezier(0,0,1,1)).
ease Specifies a transition effect that starts slowly, then speeds up, and then ends slowly (cubic-bezier(0.25,0.1,0.25,1)).
ease-in Specifies a transition effect with a slow start (equivalent to cubic-bezier(0.42,0,1,1)).
ease-out Specifies a transition effect with a slow end (equivalent to cubic-bezier(0,0,0.58,1)).
ease-in-out Specifies a transition effect that starts and ends at a slow speed (equivalent 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.

Examples

More Examples


Example

To better understand the different function values: here are five different div elements, using 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 Yourself »

Example

Same as the example above, but specifies the speed curve as 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 Yourself »
other extensions