Syntax

/* transition: property duration timing-function delay */
transition: all 0.3s ease;
transition: opacity 0.2s ease-in-out;
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
Sub-propertyDefaultDescription
transition-propertyallWhich CSS property to animate (use specific over 'all')
transition-duration0sHow long the transition takes
transition-timing-functioneaseSpeed curve of the animation
transition-delay0sWait before starting the transition

Timing Functions

ValueCurveBest For
easeSlow start, fast middle, slow endGeneral use (default)
linearConstant speedContinuous animations, progress bars
ease-inSlow start, fast endElements exiting the screen
ease-outFast start, slow endElements entering the screen
ease-in-outSlow start and endElements moving across the screen
cubic-bezier(x1,y1,x2,y2)Custom curvePrecise control — use cubic-bezier.com
steps(n)Stepped / frame-by-frameSprite animations, typewriter effect

Multiple Transitions

/* Different durations per property */
.card {
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),  /* spring */
    box-shadow 0.3s ease,
    border-color 0.2s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border-color: #2a3f60;
}

What Can Be Animated?

Properties that are animatable include: opacity, transform, color, background-color, border-color, box-shadow, width, height, margin, padding, font-size, letter-spacing, and many more.

Properties that cannot be transitioned: display, visibility (snaps instantly), content, font-family.

💡 Visibility trick: Combine opacity and visibility to animate show/hide:
transition: opacity 0.3s, visibility 0.3s;
Set both to 0/hidden to hide, 1/visible to show.

Performance

Only two properties animate at 60fps without triggering layout or paint: transform and opacity. Everything else may cause performance issues on complex pages:

/* ✅ Performant */
transition: transform 0.3s ease;   /* GPU composited */
transition: opacity 0.3s ease;     /* GPU composited */

/* ❌ May cause jank on complex pages */
transition: width 0.3s ease;       /* triggers layout */
transition: height 0.3s ease;      /* triggers layout */
transition: background-color 0.3s; /* triggers paint (usually fine) */