🍋
Menu
CSS

Transition

CSS Transition

A smooth animation between two property values triggered by a state change (e.g. hover).

Technisches Detail

CSS Transitions animate property changes over a specified duration using easing functions (ease, linear, cubic-bezier). Only animatable properties can transition — layout properties like display and grid-template cannot. Performance-critical transitions should target transform and opacity, which run on the compositor thread without triggering layout recalculation. The will-change property hints the browser to optimize for upcoming transitions by promoting elements to their own compositing layer.

Beispiel

```css
.button {
  background: #3b82f6;
  transform: scale(1);
  transition: background 200ms ease, transform 150ms ease;
}
.button:hover {
  background: #2563eb;
  transform: scale(1.05);
}
```

Verwandte Tools

Verwandte Begriffe