20 CSS Page Transitions
A page transition is an overlay that covers the viewport, a content swap that happens while it is opaque, and a reveal — swap too early and the change shows, too late and a blank frame flashes. These 20 hand-coded patterns cover that lifecycle, exit and enter timing, holding scroll position, height changes mid-transition, FLIP element continuity, route preloading, pending states, back and forward direction, and accessible focus handling. Scoped under .pt-NN; drops into React, Vue, Svelte, or Astro.
Related20 CSS View Transitions22 CSS Transitions16 CSS Fade In Animation Designs20 CSS Loading Animations
Course pickPartner: Zero to Mastery
Affiliate linkWant to build production-ready CSS layouts, animations and UI from scratch?
You just browsed 20 page transitions. Learn the Flexbox, Grid and animation thinking behind them, so the next component starts in your head, not in a copy-paste.
Every ZTM course in one membership: $25/month, paid yearly at $299 · 30‑day money-back guarantee
The CSS Bootcamp. We may earn a commission, at no extra cost to you.
02. Exit and Enter Timing Without Overlap (opens in a new tab)
03. Holding Scroll Position Across a Route Swap (opens in a new tab)
04. Route Transitions Between Different Page Heights (opens in a new tab)
05. FLIP Element Continuity Without the API (opens in a new tab)
06. Preloading Routes So Transitions Never Stall (opens in a new tab)
07. Pending State When the Next Route Is Slow (opens in a new tab)
08. Back and Forward Navigation Transition Behavior (opens in a new tab)
09. Accessible Route Change Focus and Announcements (opens in a new tab)
10. CSS Page Fade Transition on Route Change (opens in a new tab)
11. Slide Page Transition Left and Right (opens in a new tab)
12. Zoom Page Transition Scale In and Out (opens in a new tab)
13. Clip Path Wipe Page Transition Effect (opens in a new tab)
clip-path wipe used as the overlay's cover and reveal: the panel is not moved, its visible shape is. Cheap to composite, easy to angle, and the most versatile of the mask-based effects — a straight edge, a diagonal, or a chevron all come from editing one polygon. Three angles are switchable so the difference is visible rather than described.14. Blur Page Transition Between Routes (opens in a new tab)
filter: blur() across a full viewport is the most expensive transition in this collection, and the cost meter says so.15. Book Page Turn Transition Effect CSS (opens in a new tab)
perspective on the wrong ancestor and the whole thing collapses to a flat squash.16. Ink Bleed Mask Page Transition (opens in a new tab)
mask-image: an inked panel spreads across the viewport from a point, holds while the route swaps, then contracts away toward the opposite corner. No script, no clip-path polygon — the shape is a soft radial mask, which is what makes the edge read as ink on paper rather than as a geometric wipe.17. Shatter Page Transition with Clip Path Tiles (opens in a new tab)
18. Split Curtain Page Transition Effect (opens in a new tab)
@keyframes, no script.19. Terminal Text Page Transition Overlay (opens in a new tab)
aria-hidden, and under reduced motion nothing types at all — the line appears complete and the swap happens immediately.20. Brush Stroke Page Transition Mask (opens in a new tab)
stroke-dashoffset paints the mask on, which sweeps the overlay across the viewport as a single stroke and then lifts it the same way. Higher fidelity than the radial bleed in demo 16, and the place where namespacing matters most — SVG mask ids are document-global, so two demos both defining one means the second silently wins.Frequently asked questions
How do you make a page transition in CSS and JavaScript?
aria-hidden="true" throughout so a screen reader never announces a decorative full-viewport element. Demo 01 renders the phase timeline as a visible diagram with each step labelled.Should I use the View Transitions API instead?
document.startViewTransition handles the snapshot, the crossfade and the element morphing for you, and it does so more smoothly than hand-rolled code. Our css-view-transitions collection covers it in depth across 20 demos. Three situations still call for building it yourself. Safari support arrived late and a large share of production traffic sits on older versions, so a fallback path is required rather than optional. Some routers own the DOM in ways that make handing control to the browser's snapshot mechanism awkward. And some effects — a book page turn, a shatter, a brush stroke mask — are not crossfades and cannot be expressed through the API's model at all. The machinery in this collection is what runs in those cases, and it is also what the API's fallback path degrades to.Why does my page jump to the top during a route transition?
history.scrollRestoration to 'manual' so the browser stops applying its own guess on top of yours. Demo 03 shows all three policies side by side with the live scroll offset displayed.How do I stop the layout jumping when routes have different heights?
How do I animate an element from one page to another without the API?
getBoundingClientRect, apply the Last state by moving it to its destination, Invert the visual change with a transform that puts it back where it appeared to be, then Play by transitioning that transform to identity. The result is an element that appears to travel continuously between two layouts even though it was never actually animated along a path. The trap is measurement timing: read layout before the browser paints the Last state, or you measure the wrong frame and the element animates from somewhere unexpected. Demo 05 shows a thumbnail growing into a detail hero with the measurement overlay visible.How do I show a loading state when the next route is slow?
css-loading-animations.Should the back button replay the transition or reverse it?
popstate fires after the URL has already changed, so by the time you handle it the direction is no longer inferable from the current state. Direction has to be recorded at push time and read back on pop, which usually means storing an index in the history state object and comparing it against the previous one. Demo 08 shows direction tracked through an in-memory history stack, since a sandboxed demo cannot push real entries.Are client-side route transitions accessible?
tabindex="-1" so it can receive focus without entering the tab order. Announce the new page title through a polite live region, so the change is heard without interrupting. And keep the transition overlay aria-hidden, so its decorative content is never read aloud. Under prefers-reduced-motion, reduce the transition to a near-instant swap rather than removing it in a way that strands an element mid-animation. Demo 09 ships all of it with a simulated announcement log.Related collections
20 CSS Animated Buttons
20 hand-coded CSS animated buttons — neon glow, ripple, 3D press, liquid fill, jelly bounce, shine sweep, animated border, moving gradient CTA, text flip, submit success state, add-to-cart progress, download icon, hamburger-to-close, toggle switch, loading spinner inside button, next/prev arrow nav, and ghost button background reveal. Half pure CSS, half lightweight JS for production interactions.
11 CSS animation-timeline Demos
11 pure CSS animation-timeline demos built on the W3C scroll() and view() spec — reading progress bar, view-timeline fade & reveal, shrinking sticky header, stacking cards, horizontal scroll section, parallax hero, container shadow indicators, reverse-scroll columns, text scrim reveal, cover card to sticky header, and image zoom / clip-path wipe. Zero JS, off the main thread, Core Web Vitals safe. Copy-paste ready.
25 CSS Background Animations
25 hand-coded CSS background animations for SaaS hero sections, developer tool documentation, agency portfolios, gaming and Web3 landing pages, seasonal e-commerce campaigns, and dark-mode dashboards. Covers full-screen gradient shifts, animated mesh gradients, aurora borealis glow, cursor spotlight follow, interactive water ripples, dot grid and diagonal stripe patterns, SVG grain and noise texture overlays, topographic contour lines, layered SVG waves, plasma and lava lamp fluids, bokeh light blur, particle constellation networks, matrix digital rain, synthwave 3D perspective grids, starfield warp speed, CRT scanline overlays, fog and mist drift, morphing organic blobs, floating glassmorphism orbs, halftone dot patterns, starry night skies, floating geometric shapes, rising bubbles, and falling snow. 20 are pure CSS with zero JavaScript; the 5 that need it use vanilla canvas or pointer tracking with no dependencies. Every background animates compositor-only properties so it never blocks the main thread, is scoped under a .bga-NN prefix for no-collision pasting, guards prefers-reduced-motion, and ports unchanged to React, Vue, Svelte, Astro, Next.js and Tailwind.



















