CSS Transitions in CSS

From the CSS cheat sheet ยท Transitions ยท verified Jul 2026

CSS Transitions

Animate property changes smoothly between states

css
.btn {
  background: #3b82f6;
  transition: background 200ms ease;
}
.btn:hover {
  background: #2563eb;
}

/* Shorthand: property duration timing-function delay */
transition: all 300ms ease-in-out;
transition: transform 200ms ease, opacity 200ms ease;
๐Ÿ’ก Transition individual properties instead of "all" โ€” better performance and control
โšก Only transition cheap properties: transform, opacity, color, background, box-shadow
๐Ÿ“Œ Avoid transitioning width/height/top/left โ€” they trigger layout recalculation (janky)
๐ŸŸข See the CSS Animations sheet for keyframes, complex sequences, and timing deep-dives
transitionhoveranimation
Back to the full CSS cheat sheet