New researchTechnical SEO & AI Search · 2027Explore the framework

CSS animations and layout shifts: find the CLS culprit

Find CSS transitions that move surrounding content, distinguish visual motion from CLS, and replace layout-changing animations with safer patterns.

Part of the Core Web Vitals series. For the full picture, start with Core Web Vitals: what they are, how they affect SEO and how to improve them.

A moving element is not necessarily a layout shift. CSS can move a card visually with transform without changing its neighbors’ positions, or it can animate height and push a whole page downward. This focused guide shows how to tell those cases apart and fix animation-driven CLS. For the metric and its other causes, start with Cumulative Layout Shift.

Which CSS animations can cause layout shifts?

Animations that change layout geometry can move other visible elements. The web.dev CLS guide recommends using transform: translate() instead of animating top, right, bottom or left, and transform: scale() instead of changing width or height for visual effects. Its optimization guide explains that composited translations cannot affect surrounding layout and therefore do not count toward CLS.

Animation pattern What to check Safer direction
top or left on a positioned element Do other elements shift? Use transform: translate() for visual travel
height on a banner or accordion Does content below move unexpectedly? Reserve space or make the change immediate after input
width on a navigation item Do adjacent items reflow? Use transform within a fixed-size slot
transform on a card Is surrounding layout stable? Keep it if motion is usable and accessible

Do not replace every layout change with transform blindly. A visual transform can overlap other content or leave a misleading hit area if the component was designed to take up new space. Solve the component’s layout behavior first.

When does an animation count toward CLS?

CLS counts unexpected shifts of visible elements. The web.dev CLS definition excludes shifts within 500 milliseconds of qualifying user input, such as a direct click, because the user expected a response. Scrolling does not qualify. A delayed dropdown, sticky header transition or promotional strip that pushes content after a scroll can therefore still count.

The metric measures the largest burst across a page visit, not just the initial load. A page can pass a load-only Lighthouse test and still have poor field CLS after a user scrolls or navigates within a single-page app. Check the Core Web Vitals audit to see which templates have field problems before debugging individual transitions.

How do you find the animation causing the shift?

Use a controlled reproduction rather than guessing from the CSS file. The web.dev debugging guide recommends interacting with the page while recording layout shifts. In Chrome DevTools Performance, watch the Layout Shifts track and inspect the moved elements and timing.

  1. Start a recording before the animation can trigger. Test load, hover, scroll, delayed UI and SPA route changes separately.
  2. Find the shift cluster and note which elements moved. The highlighted element may be a victim, not the component that changed layout above it.
  3. Match the shift time to the transition or DOM update. Inspect the animated property and whether the component has reserved space.
  4. Change one pattern, replay the same flow and compare the shift entries.
  5. Check field data after deployment. A lab fix is encouraging but does not prove the real-user CLS percentile improved.

If an image or font causes the movement rather than CSS motion, use the image Core Web Vitals guide or font loading guide instead.

How should you fix the interaction?

For a decorative slide or zoom, keep the element in a stable layout box and animate transform or opacity. For an expanding panel, choose whether it should overlay, reserve space or immediately reflow after the user acts. Do not insert a new banner above reading content after a timer. Test keyboard interaction and honor prefers-reduced-motion, which the web.dev CLS guide also calls out.

The goal is not a page with no motion. It is a page where motion does not unexpectedly relocate the content or control the person is using.

Animation and CLS checklist

  • Reproduce load and post-load interaction flows.
  • Inspect the cause of the movement, not only the shifted element.
  • Replace decorative layout-property transitions with transform or opacity where appropriate.
  • Reserve space for expanding or inserted UI when it would otherwise push content.
  • Test click timing, scroll behavior and reduced-motion preferences.
  • Verify field CLS, not only a load-only lab run.

Frequently asked questions

Do all CSS animations hurt CLS?

No. Composited transform animations do not change other elements' layout positions and do not count toward CLS. A transition that changes layout properties can contribute if it causes unexpected movement of visible elements.

Does an animation after a click count as CLS?

A layout shift occurring within 500 milliseconds of a qualifying user input is usually excluded as expected. Scroll is not such an input, and delayed movement after the window can still count.

Is transform always the right fix?

No. Transform is useful for purely visual motion, but you still need enough reserved space, accessible focus behavior and reduced-motion support. A panel that truly needs to expand may need a different layout design.

Why does Lighthouse show no shift while users see one?

A normal Lighthouse load may not exercise hover, scrolling, delayed banners or app navigation. Record those flows in DevTools and compare with field CLS to investigate post-load shifts.

· Founder, Crawlens

Dien builds Crawlens, a desktop crawler for technical SEO audits, and writes about the checks it runs: crawling, indexing, rendering and Search Console data.

Audit your own site with Crawlens

Crawl, run 70 checks, and see them next to Search Console and Core Web Vitals data.

Download free for Windows