Skip to main content
← 🎨 CSS as a design systemΒ·Module B7 Β· Lesson 8
TaskAdd view-transition support: <meta name='view-transition' content='same-origin'>. .hero-image has view-transition-name: hero. ::view-transition-old(root) and ::view-transition-new(root) get animation-duration: 0.4s.

View transitions: cross-page motion

100 XP8 min
Theory

Recap from A7 lesson 8 β€” now applied to layouts

<meta name="view-transition" content="same-origin" />

That meta tag opts the page into cross-document transitions. Click a link β†’ browser captures BEFORE and AFTER snapshots β†’ crossfades them. Free.

Naming elements that should PAIR

Hero animations (iOS-style):

.hero-image { view-transition-name: hero; }

If the same view-transition-name exists on BOTH pages, the browser ANIMATES between their positions/sizes. A thumbnail on page A morphs into a full-size image on page B.

Unique names per element pair. Don't name multiple elements the same β€” only one would pair.

Pseudo-elements for control

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.3s;
}

::view-transition-old(hero) {
  animation-name: hero-out;
}

Pseudos give you the OLD (outgoing) and NEW (incoming) views as separate animatable layers. Customize each.

When to use

  • SPA-feel multi-page sites β€” feels like a single app.
  • E-commerce: product list β†’ product detail with image morph.
  • Blog: title in list β†’ title in article.

Don't overdo it. Most navigations should just be instant. Use named transitions sparingly on the 2-3 most important state changes.

πŸ”’

Sign up to start coding

Theory is open to everyone. The interactive editor, live preview, and check are unlocked with a 7-day free trial β€” card required, cancel anytime.

Sign up β€” free trial β†’

First 10 lessons in each track are free. No card needed for those.

← PreviousNext lesson β†’

Get one Python or web tip a day β€” by email

Short, hand-written, no spam. Unsubscribe in one click.