Skip to main content

CSS Transition Speed Curve

The transition-timing-function property sets the speed curve of a transition effect.

It can have one of these values:

  • ease - starts slow, goes fast, then ends slow (this is the default)
  • linear - keeps the same speed from start to end
  • ease-in - starts slow
  • ease-out - ends slow
  • ease-in-out - has a slow start and a slow end
  • cubic-bezier(n,n,n,n) - lets you set your own values in a cubic-bezier function

Example

Different speed curves for the transition:

Prompt
Create a page with five div elements that grow wider on hover, each using a different transition-timing-function value: linear, ease, ease-in, ease-out, and ease-in-out. Label each div with the name of its timing function.
Output: complete HTML page

CSS Transition Delay

The transition-delay property sets a delay before the transition starts.

The value is set in seconds (s) or milliseconds (ms).

Example

Add a 1 second delay before the transition starts:

Prompt
Create a page with a div that changes width on hover, using a CSS transition with a 1 second delay before starting.
Output: complete HTML page

Transition + Transform

Div transition with transform

This example combines transition and transform on a <div> element:

Prompt
Create a page with a div that transitions its width, height, background-color, and transform (rotate) on hover using a 2 second duration for each property.
Output: complete HTML page

Button transition with transform

This example combines transition and transform on a button:

Prompt
Create a page with a button that transitions its background-color and transform (scale) on hover using ease-out timing over 1 second.
Output: complete HTML page

More Transition Examples

The CSS transition properties can be written one by one, or by using the shorthand transition property.

Individual properties

Setting each transition property separately:

Prompt
Create a page with a div that grows wider on hover, using the individual transition properties: transition-property set to width, transition-duration set to 2s, transition-timing-function set to linear, and transition-delay set to 1s.
Output: complete HTML page

Shorthand property

Using the shorthand transition property:

Prompt
Create a page with a div that grows wider on hover, using the shorthand transition property: width 2s linear 1s.
Output: complete HTML page