iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

CSS Animatable

Most CSS properties can be animated with transition or @keyframes — but not all. Here are the ones that matter, plus performance notes.

Cheap, GPU-accelerated

PropertyWhy it's fast
transformCompositor-only; no layout or paint.
opacitySame — compositor-only.
filterCompositor on modern browsers.

Animatable but pricier (triggers paint or layout)

PropertyWhat changes when it animates
color, background-colorPaint only — moderate cost.
box-shadowPaint — can be expensive with large blurs.
border-radiusPaint.
width, height, top, left, padding, marginLayout + paint — usually avoid.

Not directly animatable (use a workaround)

PropertyWorkaround
displayUse visibility + opacity, or modern @starting-style.
height: autoUse grid-template-rows: 0fr → 1fr trick.
z-indexDiscrete — snaps at 50% by default.
Tip: Animate only transform and opacity in the inner loop of a fast scroll or 60fps animation. Everything else risks jank on weaker devices.

Example

Example
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Verdana, sans-serif; }
.box { background: #04AA6D; color: #fff; padding: 20px; border-radius: 6px; }
</style>
</head>
<body>

<h1>CSS Animatable</h1>
<div class="box">Edit the CSS on the left, then click Run &raquo;</div>

</body>
</html>
Try it Yourself »

Exercise

Which two properties are compositor-only and cheap to animate?

Answer: and opacity

Test yourself

Q1. Which property is *not* easily animatable without tricks?
Q2. Which two are compositor-only (cheap)?
Q3. Which CSS feature animates display in modern browsers?

Discussion

Loading…