effects

transition

Shorthand that animates changes to specified CSS properties over a duration. It is the simplest way to add polish to hover, focus, and state changes.

transition: <property> <duration> <timing-function> <delay> [, ...]

Common values

Value Effect
all .2s ease Animate every animatable property
opacity .3s ease-in-out Fade transition
transform .2s cubic-bezier(.4,0,.2,1) Snappy transform animation
none Disable transitions
background-color .15s linear Quick color swap

Examples

.btn { transition: background-color .15s ease, transform .15s ease; }

Smooth hover feedback

.fade { transition: opacity .3s; opacity: 0; } .fade.show { opacity: 1; }

Fade-in via class toggle

.card:hover { transform: translateY(-4px); transition: transform .2s; }

Card lift on hover

Gotcha

Not every property is animatable; display and height: auto notably jump instead of tweening.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox