Web Analytics

CSS Transitions

Beginner ~9 min read

What are Transitions?

Transitions create smooth changes between property values. Perfect for hover effects, focus states, and interactive elements!

Basic Transition

Use transition to animate property changes. Hover over the boxes to see the effect!

HTML
CSS
JS

Transition Duration

transition-duration controls how long the transition takes. Use seconds (s) or milliseconds (ms).

HTML
CSS
JS

Timing Functions

transition-timing-function controls the speed curve: ease, linear, ease-in, ease-out, ease-in-out.

HTML
CSS
JS

Transition Delay

transition-delay adds a pause before the transition starts.

HTML
CSS
JS

Multiple Properties

Transition multiple properties at once by separating them with commas, or use all.

HTML
CSS
JS

Transition Shorthand

Combine all transition properties: transition: property duration timing-function delay.

HTML
CSS
JS
Pro Tip: Keep transitions fast (0.2-0.3s) for better UX. Slow transitions can make your site feel sluggish!

Summary

  • transition-property - Which property to animate
  • transition-duration - How long (s or ms)
  • transition-timing-function - Speed curve
  • transition-delay - Wait before starting
  • Shorthand: transition: property duration timing delay
  • Use all to transition all properties

Quick Quiz

Which timing function creates a constant speed transition?

A
ease
B
linear
C
ease-in-out
D
ease-out