Smooth Scroll and Parallax Effects

Updated 2026-10-15. 9 effects.

Parallax scrolling moves background layers more slowly than the foreground so a section feels deep. Do it with translate on each layer, driven by a CSS scroll timeline or one passive scroll listener, never by background-attachment. Smooth scrolling between anchors needs only scroll-behavior: smooth, which every current browser supports.

Use parallax where depth tells part of the story: a landscape hero, a product shot over its backdrop, a photo inside a card that drifts slightly as it passes. Keep the speed difference small; a layer moving at nine tenths of the scroll speed already reads as distance, and large differences make text hard to follow.

Smooth scrolling comes in two kinds. Native scroll-behavior: smooth eases jumps to anchors and keeps the browser's own scrolling, which is what most sites need. Eased wheel scrolling, which delays the page behind the wheel, feels luxurious to some and sluggish to others; the version here keeps it to one container and turns itself off for touch and reduced motion.

Compare them

EffectBuilt withSize (gzipped)Running costBrowser support
Layered Mountain Landscape Hero With Depth ParallaxCSS and a small script2.7 KBOne transform per layer per scroll frame from a passive listener, paused with the mist when the hero leaves the screen.All current browsers
Anchor Link Navigation With Motion Safe Smooth ScrollCSS only2.3 KBThe glide is native browser scrolling; the script only reads section positions once per scroll frame.All current browsers
Eased Inertia Scroll Inside One Reading PanelCSS and a small script2.9 KBA frame loop runs only while a glide is settling and stops the moment it reaches its target or the panel leaves the screen.All current browsers
Floating Product Photo Rising Over Its Backdrop on ScrollCSS and a small script2.5 KBTwo transforms and one opacity per scroll frame from a passive listener, paused when the section is off screen.All current browsers
Oversized Type Rows Sliding at Different Scroll SpeedsCSS and a small script1.9 KBThree transforms per scroll frame from a passive listener, paused when the section is off screen.All current browsers
Photo Cards Grid With Image Parallax Inside FramesCSS and a small script2.3 KBA passive scroll listener writes one transform per visible photo per frame and stops when the grid leaves the screen.All current browsers
Photo Gallery Columns Moving at Different Scroll SpeedsCSS and a small script2.3 KBThree column transforms per scroll frame from a passive listener; nothing runs while the gallery is off screen.All current browsers
Scroll Snap Full Height Sections With Gentle ParallaxCSS and a small script2.1 KBSnapping is native CSS; a passive listener writes three transforms per scroll frame and idles off screen.All current browsers
Sticky Photo Backdrop With Cards Passing OverCSS and a small script2.3 KBSticky positioning is handled by the browser; the script only writes one scale per scroll frame and stops off screen.All current browsers

Layered Mountain Landscape Hero With Depth Parallax

A dawn mountain scene for a small valley lodge, drawn as four inline SVG ridges, a low sun and a band of drifting mist. As the section scrolls, each layer slides at its own rate, so the far peaks seem to hang back while the dark foreground carries the buttons up and away. The headline sits between the sky and the ridges, which lets the nearer hills rise over it. On phones the ridges stretch to the screen width and the copy stays centred above them.

<div class="w6lnd" tabindex="0" role="region" aria-label="Haldor Ridge Lodge, scrollable preview">
  <header class="w6lnd-hero">
    <div class="w6lnd-layer w6lnd-sun" data-depth="0.55" aria-hidden="true"></div>
    <div class="w6lnd-hint" aria-hidden="true">Scroll inside</div>
    <div class="w6lnd-layer w6lnd-copy" data-depth="0.35">
      <p class="w6lnd-eyebrow">Haldor Ridge Lodge</p>
      <h1 class="w6lnd-title">Wake up above the cloud line</h1>
      <p class="w6lnd-lede">A small lodge at the head of the valley, with the ridge outside every window.</p>
    </div>
    <div class="w6lnd-layer w6lnd-ridge" data-depth="0.42" aria-hidden="true"><svg viewBox="0 0 1440 400" preserveAspectRatio="none"><path fill="#e8c39c" d="M0 250 L110 205 L230 228 L370 150 L500 212 L640 168 L780 118 L930 190 L1060 146 L1210 214 L1330 172 L1440 198 V400 H0Z"/></svg></div>
    <div class="w6lnd-layer w6lnd-ridge" data-depth="0.3" aria-hidden="true"><svg viewBox="0 0 1440 400" preserveAspectRatio="none"><path fill="#c98f6e" d="M0 292 L150 238 L300 276 L450 206 L620 268 L760 226 L910 286 L1080 216 L1250 270 L1440 236 V400 H0Z"/></svg></div>
    <div class="w6lnd-layer w6lnd-ridge" data-depth="0.18" aria-hidden="true"><svg viewBox="0 0 1440 400" preserveAspectRatio="none"><path fill="#8d5a49" d="M0 330 C180 286 330 270 520 312 S850 356 1040 304 S1310 270 1440 314 V400 H0Z"/></svg></div>
    <div class="w6lnd-mist" aria-hidden="true"></div>
    <div class="w6lnd-front" aria-hidden="true"><svg viewBox="0 0 1440 400" preserveAspectRatio="none"><path fill="#21181a" d="M0 250 C220 196 470 222 720 240 S1180 204 1440 232 V400 H0Z"/></svg></div>
    <div class="w6lnd-ctas">
      <a class="w6lnd-btn" href="#">Check winter dates</a>
      <a class="w6lnd-btn w6lnd-ghost" href="#">See the trails</a>
    </div>
  </header>
  <section class="w6lnd-more">
    <h2>Quiet rooms, early light and a porch that opens onto three trails.</h2>
    <ul>
      <li><h3>Twelve rooms</h3><p>Every room faces the eastern ridge, so first light reaches the bed before the alarm does.</p></li>
      <li><h3>Marked trails</h3><p>Three loops leave from the porch, from a gentle valley walk to a full day on the high saddle.</p></li>
      <li><h3>A slow kitchen</h3><p>Breakfast runs until eleven and dinner is one long table, cooked from what the valley grows.</p></li>
    </ul>
  </section>
</div>
<style>
  /* Change these: box height (remove height and overflow to use the page scroll), sky colours, and the depth of each layer in its data-depth attribute (0 = moves with the page, 1 = stands still). */
  .w6lnd { --w6lnd-h: 640px; --w6lnd-sky-top: #f6e3c8; --w6lnd-sky-low: #eab98f; --w6lnd-ground: #21181a;
    position: relative; height: var(--w6lnd-h); overflow-y: auto; overscroll-behavior: contain; background: var(--w6lnd-ground); color: #2a1b19; font-family: ui-sans-serif, system-ui, sans-serif; }
  .w6lnd:focus-visible { outline: 2px solid #8d5a49; outline-offset: -2px; }
  .w6lnd-hero { position: relative; height: var(--w6lnd-h); overflow: hidden; background: linear-gradient(var(--w6lnd-sky-top), #f2d3ae 55%, var(--w6lnd-sky-low)); }
  .w6lnd-layer { will-change: transform; }
  .w6lnd-sun { position: absolute; left: 64%; top: 44%; width: 128px; height: 128px; margin-left: -64px; border-radius: 50%; background: #fbeedb; box-shadow: 0 0 80px 30px rgba(251,238,219,.55); }
  .w6lnd-hint { position: absolute; right: 16px; top: 16px; z-index: 3; padding: 6px 12px; border-radius: 999px; background: rgba(42,27,25,.8); color: #f6e3c8; font-size: 12px; font-weight: 500; pointer-events: none; transition: opacity .5s ease; }
  .w6lnd-moved .w6lnd-hint { opacity: 0; }
  .w6lnd-copy { position: absolute; left: 0; right: 0; top: 64px; z-index: 1; padding: 0 24px; text-align: center; }
  .w6lnd-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .3em; text-transform: uppercase; color: #6e3f30; }
  .w6lnd-title { margin: 16px auto 0; max-width: 48rem; font-size: clamp(36px, 6.6vw, 78px); font-weight: 600; line-height: 1.02; letter-spacing: -.02em; }
  .w6lnd-lede { margin: 16px auto 0; max-width: 28rem; font-size: 16px; line-height: 1.6; color: #4a2c24; }
  .w6lnd-ridge { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; height: 62%; }
  .w6lnd svg { display: block; width: 100%; height: 100%; }
  .w6lnd-mist { position: absolute; left: -10%; right: -10%; bottom: 16%; z-index: 2; height: 96px; background: linear-gradient(transparent, rgba(246,227,200,.4), transparent); animation: w6lnd-drift 26s ease-in-out infinite alternate; }
  .w6lnd[data-paused] .w6lnd-mist { animation-play-state: paused; }
  @keyframes w6lnd-drift { from { transform: translate3d(-4%,0,0); } to { transform: translate3d(4%,0,0); } }
  .w6lnd-front { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; height: 30%; }
  .w6lnd-ctas { position: absolute; left: 0; right: 0; bottom: 32px; z-index: 3; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; padding: 0 24px; }
  .w6lnd-btn { display: inline-flex; align-items: center; height: 48px; padding: 0 24px; border-radius: 999px; background: var(--w6lnd-sky-top); color: var(--w6lnd-ground); font-size: 14px; font-weight: 600; text-decoration: none; }
  .w6lnd-btn:hover { background: #fff; }
  .w6lnd-ghost { background: transparent; color: var(--w6lnd-sky-top); border: 1px solid rgba(246,227,200,.5); }
  .w6lnd-ghost:hover { background: transparent; border-color: var(--w6lnd-sky-top); }
  .w6lnd-btn:focus-visible { outline: 2px solid var(--w6lnd-sky-top); outline-offset: 3px; }
  .w6lnd-more { max-width: 64rem; margin: 0 auto; padding: 40px 24px 80px; color: #f1dcc4; }
  .w6lnd-more h2 { margin: 0; max-width: 36rem; font-size: clamp(24px, 3vw, 30px); font-weight: 600; line-height: 1.3; }
  .w6lnd-more ul { list-style: none; margin: 40px 0 0; padding: 0; display: grid; gap: 32px; }
  @media (min-width: 640px) { .w6lnd-more ul { grid-template-columns: repeat(3, 1fr); } }
  .w6lnd-more li { border-top: 1px solid rgba(241,220,196,.25); padding-top: 20px; }
  .w6lnd-more h3 { margin: 0; font-size: 16px; }
  .w6lnd-more p { margin: 8px 0 0; font-size: 14px; line-height: 1.6; color: #d9bfa6; }
  @media (prefers-reduced-motion: reduce) { .w6lnd-mist { animation: none; } .w6lnd-layer { will-change: auto; } }
</style>
<script>
(function () {
  var root = document.querySelector(".w6lnd");
  if (!root) return;
  // Page scroll instead of the box: set PAGE = true and remove height and overflow from .w6lnd.
  var PAGE = false;
  var hero = root.querySelector(".w6lnd-hero");
  var layers = [].slice.call(root.querySelectorAll("[data-depth]"));
  var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
  var frame = 0, on = true;
  function draw() {
    frame = 0;
    var s = PAGE ? Math.max(0, -hero.getBoundingClientRect().top) : root.scrollTop;
    root.classList.toggle("w6lnd-moved", s > 8);
    if (reduce) return;
    layers.forEach(function (l) {
      l.style.transform = "translate3d(0," + (s * l.getAttribute("data-depth")).toFixed(1) + "px,0)";
    });
  }
  function req() { if (on && !frame) frame = requestAnimationFrame(draw); }
  new IntersectionObserver(function (e) {
    on = e[0].isIntersecting;
    root.toggleAttribute("data-paused", !on);
    if (on) req();
  }).observe(root);
  (PAGE ? window : root).addEventListener("scroll", req, { passive: true });
})();
</script>

With reduced motion: The landscape stays in its composed starting position and the mist stops drifting.

Running cost: One transform per layer per scroll frame from a passive listener, paused with the mist when the hero leaves the screen.

  • Change how far back each ridge sits with its `data-depth` attribute (or the `depth` value in the `LAYERS` array): 0 travels with the page, 1 stands still, and values between 0.2 and 0.7 read as believable distance.
  • Repaint the sky with `--w6lnd-sky-top` and `--w6lnd-sky-low`, and the ground with `--w6lnd-ground`; keep the front ridge fill equal to the ground so the hero runs into the next section without a seam.
  • Swap the mountains for your own skyline by replacing the `d` path in each layer. Keep the 1440 by 400 viewBox and close every path along the bottom edge with `V400 H0Z`.
  • To drive it from the page scroll instead of the preview box, set `PAGE = true` and remove `height` and `overflow-y` from `.w6lnd`.

Full page for Layered Mountain Landscape Hero With Depth Parallax

A library trust's year-in-review with a sticky row of section links. Clicking a link glides to its section because `scroll-behavior: smooth` is set, but only inside a `prefers-reduced-motion: no-preference` query, so visitors who asked for less motion jump instantly. A short script marks the link for the section in view. The link row scrolls sideways on narrow phones.

<div class="w6anc">
  <header class="w6anc-head">
    <div>
      <p class="w6anc-eyebrow">Northcote Library Trust</p>
      <h2>A year on the shelves</h2>
    </div>
    <span class="w6anc-hint" aria-hidden="true">Scroll inside</span>
  </header>
  <nav class="w6anc-nav" aria-label="Report sections">
    <ul>
      <li><a href="#w6anc-rooms" aria-current="location">Reading rooms</a></li>
      <li><a href="#w6anc-van">Mobile library</a></li>
      <li><a href="#w6anc-archive">Archive</a></li>
      <li><a href="#w6anc-accounts">Accounts</a></li>
    </ul>
  </nav>
  <div class="w6anc-body">
    <section id="w6anc-rooms" tabindex="-1"><div><p class="w6anc-num">01</p><h3>The reading rooms stayed open late</h3><p>Thursday hours ran to nine all year, and the long table by the west window became the quiet study spot for the sixth form across the road. We added lamps, not rules.</p></div></section>
    <section id="w6anc-van" tabindex="-1"><div><p class="w6anc-num">02</p><h3>The van found three new stops</h3><p>The mobile library now parks at the ferry landing, the care home on Fell Road and the allotments on Saturday mornings, where most loans turned out to be seed catalogues.</p></div></section>
    <section id="w6anc-archive" tabindex="-1"><div><p class="w6anc-num">03</p><h3>The parish maps came home</h3><p>A volunteer team cleaned, flattened and boxed the old parish maps. They can be seen by appointment in the archive room, and the most asked-for sheets now hang in the stairwell.</p></div></section>
    <section id="w6anc-accounts" tabindex="-1"><div><p class="w6anc-num">04</p><h3>Where the money went</h3><p>Most of the year's spending went on staff hours and new stock. The full accounts, with every grant listed by name, are in the downloadable report at the foot of this page.</p></div></section>
    <a class="w6anc-btn" href="#">Download the full report</a>
  </div>
</div>
<style>
  /* Change these: box height (remove height and overflow, and put scroll-behavior on html, to use the page), the sticky nav offset in scroll-margin-top, and the active link colour. */
  .w6anc { --w6anc-ink: #0f172a; --w6anc-muted: #475569; --w6anc-line: #e2e8f0;
    position: relative; height: 600px; overflow-y: auto; overscroll-behavior: contain; background: #fff; color: var(--w6anc-ink); font-family: ui-sans-serif, system-ui, sans-serif; }
  @media (prefers-reduced-motion: no-preference) { .w6anc { scroll-behavior: smooth; } }
  .w6anc section { scroll-margin-top: 76px; }
  .w6anc-head { max-width: 56rem; margin: 0 auto; padding: 40px 20px 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
  .w6anc-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--w6anc-muted); }
  .w6anc-head h2 { margin: 8px 0 0; font-size: clamp(30px, 4vw, 36px); font-weight: 600; letter-spacing: -.02em; }
  .w6anc-hint { flex-shrink: 0; margin-top: 4px; padding: 6px 12px; border-radius: 999px; background: #f1f5f9; color: var(--w6anc-muted); font-size: 12px; font-weight: 500; transition: opacity .5s ease; }
  .w6anc-moved .w6anc-hint { opacity: 0; }
  .w6anc-nav { position: sticky; top: 0; z-index: 1; border-top: 1px solid var(--w6anc-line); border-bottom: 1px solid var(--w6anc-line); background: rgba(255,255,255,.96); }
  .w6anc-nav ul { list-style: none; max-width: 56rem; margin: 0 auto; padding: 8px 12px; display: flex; gap: 4px; overflow-x: auto; }
  .w6anc-nav li { flex-shrink: 0; }
  .w6anc-nav a { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border-radius: 999px; color: var(--w6anc-muted); font-size: 14px; font-weight: 500; text-decoration: none; }
  .w6anc-nav a:hover { background: #f1f5f9; color: var(--w6anc-ink); }
  .w6anc-nav a[aria-current] { background: var(--w6anc-ink); color: #fff; }
  .w6anc-nav a:focus-visible, .w6anc-btn:focus-visible { outline: 2px solid var(--w6anc-ink); outline-offset: 2px; }
  .w6anc-body { max-width: 56rem; margin: 0 auto; padding: 0 20px 96px; }
  .w6anc section { display: grid; gap: 24px; padding: 48px 0; border-bottom: 1px solid var(--w6anc-line); outline: none; }
  .w6anc section:last-of-type { border-bottom: 0; }
  @media (min-width: 640px) { .w6anc-head, .w6anc-body { padding-left: 40px; padding-right: 40px; } }
  .w6anc-num { margin: 0; font-size: 14px; font-weight: 500; color: var(--w6anc-muted); font-variant-numeric: tabular-nums; }
  .w6anc h3 { margin: 8px 0 0; font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
  .w6anc section p:not(.w6anc-num) { margin: 12px 0 0; max-width: 65ch; font-size: 16px; line-height: 1.65; color: var(--w6anc-muted); }
  .w6anc-btn { margin-top: 32px; display: inline-flex; align-items: center; height: 44px; padding: 0 20px; border-radius: 8px; border: 1px solid #cbd5e1; color: var(--w6anc-ink); font-size: 14px; font-weight: 600; text-decoration: none; }
  .w6anc-btn:hover { border-color: var(--w6anc-ink); }
</style>
<script>
(function () {
  // The smooth jump itself is pure CSS; this only marks the link for the section in view.
  var box = document.querySelector(".w6anc");
  if (!box) return;
  var OFFSET = 90; // a section counts as current once its top passes this far below the box top
  var links = [].slice.call(box.querySelectorAll(".w6anc-nav a"));
  var frame = 0;
  function update() {
    frame = 0;
    var top = box.getBoundingClientRect().top + OFFSET, cur = links[0];
    links.forEach(function (a) {
      var s = box.querySelector(a.getAttribute("href"));
      if (s && s.getBoundingClientRect().top <= top) cur = a;
    });
    if (box.scrollTop + box.clientHeight >= box.scrollHeight - 2) cur = links[links.length - 1];
    links.forEach(function (a) { if (a === cur) a.setAttribute("aria-current", "location"); else a.removeAttribute("aria-current"); });
    box.classList.toggle("w6anc-moved", box.scrollTop > 8);
  }
  box.addEventListener("scroll", function () { if (!frame) frame = requestAnimationFrame(update); }, { passive: true });
  new IntersectionObserver(function (e) { if (!e[0].isIntersecting) { cancelAnimationFrame(frame); frame = 0; } }).observe(box);
  // reduced motion is handled in CSS: scroll-behavior is only set inside prefers-reduced-motion: no-preference
})();
</script>

With reduced motion: Links jump straight to their section with no easing, and the active link still updates.

Running cost: The glide is native browser scrolling; the script only reads section positions once per scroll frame.

  • Match `scroll-margin-top: 76px` on the sections to the height of your sticky bar so headings never land underneath it.
  • Move `scroll-behavior` from `.w6anc` to `html` when the menu drives the whole page.
  • Change `OFFSET` to decide how far down a section must reach before its link turns active.

Eased Inertia Scroll Inside One Reading Panel

A tea merchant's tasting list in a dark panel where mouse wheel input glides to a stop instead of jumping. Only this panel is eased; the page around it keeps native scrolling, and wheel input passes on to the page at either end of the list. A thin amber bar shows how far through the notes you are, and a toggle lets visitors switch the easing off.

<section class="w6inr">
  <div class="w6inr-grid">
    <div>
      <p class="w6inr-eyebrow">Kestrel Lane Tea Merchants</p>
      <h2 class="w6inr-title">This season's tasting notes</h2>
      <p class="w6inr-lede">Ten leaves we are pouring at the counter this month. Scroll the list with a mouse wheel and it glides to a stop.</p>
      <button class="w6inr-toggle" type="button" aria-pressed="true"><span class="w6inr-dot" aria-hidden="true"></span><span class="w6inr-label">Eased scrolling on</span></button>
    </div>
    <div class="w6inr-card">
      <div class="w6inr-track" aria-hidden="true"><div class="w6inr-bar"></div></div>
      <div class="w6inr-hint" aria-hidden="true">Scroll inside</div>
      <div class="w6inr-panel" tabindex="0" role="region" aria-label="Tasting notes, scrollable">
        <ol>
          <li><span>01</span><div><h3>First flush, upper slope</h3><p class="w6inr-origin">Darjeeling</p><p>Thin as a white wine, with green grape and a dry, mineral finish.</p></div></li>
          <li><span>02</span><div><h3>Smoked pine souchong</h3><p class="w6inr-origin">Fujian</p><p>Campfire on the nose, then longan sweetness once the cup cools.</p></div></li>
          <li><span>03</span><div><h3>Roasted stem hojicha</h3><p class="w6inr-origin">Kyoto</p><p>Toasted barley and cocoa, low in caffeine, good after dinner.</p></div></li>
          <li><span>04</span><div><h3>Spring dragonwell</h3><p class="w6inr-origin">Hangzhou</p><p>Flat jade leaves that taste of chestnut and fresh-cut peas.</p></div></li>
          <li><span>05</span><div><h3>Aged white peony</h3><p class="w6inr-origin">Fuding</p><p>Five years in the tin have turned the hay notes to dried date.</p></div></li>
          <li><span>06</span><div><h3>High mountain oolong</h3><p class="w6inr-origin">Lishan</p><p>Rolled pearls that open into lilac and a long, buttery finish.</p></div></li>
          <li><span>07</span><div><h3>Golden tips</h3><p class="w6inr-origin">Yunnan</p><p>Malty and round, with a note of sweet potato that takes milk well.</p></div></li>
          <li><span>08</span><div><h3>Shaded gyokuro</h3><p class="w6inr-origin">Yame</p><p>Brewed cool, it is brothy and deep, close to a light seaweed stock.</p></div></li>
          <li><span>09</span><div><h3>Ruby breakfast</h3><p class="w6inr-origin">Nantou</p><p>Cinnamon and red fruit, strong enough to stand up to a long steep.</p></div></li>
          <li><span>10</span><div><h3>Wild leaf pu-erh</h3><p class="w6inr-origin">Lincang</p><p>Earth, camphor and forest floor, and it changes over many infusions.</p></div></li>
        </ol>
      </div>
    </div>
  </div>
</section>
<style>
  /* Change these: panel height, ink and accent colours. The glide length is EASE in the script. */
  .w6inr { --w6inr-ink: #141a22; --w6inr-paper: #efe8dc; --w6inr-accent: #d9a95b; --w6inr-panel-h: 440px;
    background: var(--w6inr-ink); color: var(--w6inr-paper); padding: 56px 20px; font-family: ui-sans-serif, system-ui, sans-serif; }
  .w6inr-grid { max-width: 64rem; margin: 0 auto; display: grid; gap: 40px; }
  @media (min-width: 768px) { .w6inr-grid { grid-template-columns: 1fr 1.4fr; align-items: start; } .w6inr { padding: 56px 40px; } }
  .w6inr-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--w6inr-accent); }
  .w6inr-title { margin: 12px 0 0; font-size: 30px; line-height: 1.2; font-weight: 600; }
  .w6inr-lede { margin: 16px 0 0; max-width: 24rem; font-size: 14px; line-height: 1.6; color: #b9b2a6; }
  .w6inr-toggle { margin-top: 24px; display: inline-flex; align-items: center; gap: 12px; height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid rgba(239,232,220,.3); background: none; color: inherit; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
  .w6inr-toggle:hover { border-color: rgba(239,232,220,.7); }
  .w6inr-toggle:disabled { opacity: .7; cursor: default; }
  .w6inr-toggle:focus-visible, .w6inr-panel:focus-visible { outline: 2px solid var(--w6inr-accent); outline-offset: 2px; }
  .w6inr-panel:focus-visible { outline-offset: -2px; }
  .w6inr-dot { width: 10px; height: 10px; border-radius: 50%; background: #5b6573; }
  .w6inr-toggle[aria-pressed="true"] .w6inr-dot { background: var(--w6inr-accent); }
  .w6inr-card { position: relative; overflow: hidden; border-radius: 12px; border: 1px solid rgba(239,232,220,.1); background: #1b232d; }
  .w6inr-track { position: absolute; left: 0; right: 0; top: 0; z-index: 1; height: 2px; background: rgba(239,232,220,.1); }
  .w6inr-bar { height: 100%; background: var(--w6inr-accent); transform: scaleX(0); transform-origin: 0 50%; }
  .w6inr-hint { position: absolute; right: 16px; top: 16px; z-index: 1; padding: 6px 12px; border-radius: 999px; background: var(--w6inr-paper); color: var(--w6inr-ink); font-size: 12px; font-weight: 500; pointer-events: none; transition: opacity .5s ease; }
  .w6inr-moved .w6inr-hint { opacity: 0; }
  .w6inr-panel { height: var(--w6inr-panel-h); overflow-y: auto; overscroll-behavior: contain; padding: 0 24px; scrollbar-width: thin; scrollbar-color: #3b4656 transparent; }
  .w6inr-panel ol { list-style: none; margin: 0; padding: 16px 0; }
  .w6inr-panel li { display: grid; grid-template-columns: 2.5rem 1fr; gap: 0 8px; padding: 24px 0; border-bottom: 1px solid rgba(239,232,220,.1); }
  .w6inr-panel li:last-child { border-bottom: 0; }
  .w6inr-panel li > span { padding-top: 4px; font-size: 14px; color: var(--w6inr-accent); font-variant-numeric: tabular-nums; }
  .w6inr-panel h3 { margin: 0; font-size: 18px; font-weight: 600; }
  .w6inr-panel p { margin: 8px 0 0; font-size: 14px; line-height: 1.6; color: #cfc7ba; }
  .w6inr-panel .w6inr-origin { margin-top: 2px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: #9da6b2; }
  @media (prefers-reduced-motion: reduce) { .w6inr-hint { transition: none; } }
</style>
<script>
(function () {
  var root = document.querySelector(".w6inr");
  if (!root) return;
  var EASE = 0.12; // share of the remaining distance covered per frame; lower glides longer
  var el = root.querySelector(".w6inr-panel"), bar = root.querySelector(".w6inr-bar");
  var btn = root.querySelector(".w6inr-toggle"), label = root.querySelector(".w6inr-label");
  // Only for a mouse or trackpad; touch, pen and reduced motion keep native scrolling.
  var can = matchMedia("(hover: hover) and (pointer: fine)").matches && !matchMedia("(prefers-reduced-motion: reduce)").matches;
  var live = can, cur = el.scrollTop, target = cur, frame = 0;
  function setBtn() {
    btn.setAttribute("aria-pressed", String(live));
    label.textContent = can ? "Eased scrolling " + (live ? "on" : "off") : "Native scrolling on this device";
  }
  if (!can) btn.disabled = true;
  setBtn();
  btn.addEventListener("click", function () { live = !live; setBtn(); });
  function max() { return el.scrollHeight - el.clientHeight; }
  function step() {
    frame = 0;
    cur += (target - cur) * EASE;
    if (Math.abs(target - cur) < 0.5) cur = target;
    el.scrollTop = cur;
    if (cur !== target) frame = requestAnimationFrame(step);
  }
  el.addEventListener("wheel", function (e) {
    if (!live || e.ctrlKey) return;
    var d = e.deltaY * (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? el.clientHeight : 1);
    var t = Math.max(0, Math.min(max(), target + d));
    if (t === target && cur === target) return; // at an end: the page scrolls on
    e.preventDefault();
    target = t;
    if (!frame) frame = requestAnimationFrame(step);
  }, { passive: false });
  el.addEventListener("scroll", function () {
    if (!frame) cur = target = el.scrollTop; // keyboard, scrollbar or touch moved it
    var m = max();
    bar.style.transform = "scaleX(" + (m ? el.scrollTop / m : 0) + ")";
    root.classList.toggle("w6inr-moved", el.scrollTop > 8);
  }, { passive: true });
  new IntersectionObserver(function (e) {
    if (!e[0].isIntersecting) { cancelAnimationFrame(frame); frame = 0; cur = target = el.scrollTop; }
  }).observe(root);
})();
</script>

With reduced motion: The panel scrolls natively and the toggle reports native scrolling, so wheel input moves the list straight away.

Running cost: A frame loop runs only while a glide is settling and stops the moment it reaches its target or the panel leaves the screen.

  • Lower `EASE` from 0.12 to 0.07 for a longer glide, or raise it toward 0.25 for a quick settle.
  • Change the panel height with `--w6inr-panel-h` (or `h-[440px]` in React).
  • Recolour the bar and numbers with `--w6inr-accent`.

Floating Product Photo Rising Over Its Backdrop on Scroll

A single product feature for a small skincare maker: the bottle's photo sits in a card over a terracotta arch, and as the section passes the card rises and settles while the arch sinks a little the other way. A soft shadow under the card deepens as it reaches the middle of the view, so the product seems to hover. On phones the copy moves below the stage.

<div class="w6prd" tabindex="0" role="region" aria-label="Saltgrass Apothecary face oil, scrollable preview">
  <span class="w6prd-hint" aria-hidden="true">Scroll inside</span>
  <div class="w6prd-grid">
    <div class="w6prd-stage">
      <div class="w6prd-back" aria-hidden="true"><span>No. 4</span></div>
      <div class="w6prd-shadow" aria-hidden="true"></div>
      <div class="w6prd-card"><img src="https://images.pexels.com/photos/6694147/pexels-photo-6694147.jpeg?auto=compress&cs=tinysrgb&w=800" alt="A brown glass dropper bottle standing on a weathered piece of driftwood against a pale grey wall" width="800" height="1200"></div>
    </div>
    <div>
      <p class="w6prd-eyebrow">Saltgrass Apothecary</p>
      <h2>Night oil No. 4</h2>
      <p class="w6prd-lede">A few drops after washing, pressed in with warm hands. It sinks in before the kettle boils.</p>
      <ul>
        <li>Cold-pressed rosehip and sea buckthorn</li>
        <li>Thirty millilitres, about two months of evenings</li>
        <li>Glass bottle, refill pouch on request</li>
      </ul>
      <div class="w6prd-ctas"><a class="w6prd-btn" href="#">Add to bag, $38</a><a class="w6prd-link" href="#">Ingredients</a></div>
    </div>
  </div>
  <div class="w6prd-end">Blended in small batches in a coastal workshop and shipped in paper, never plastic.</div>
</div>
<style>
  /* Change these: colours, box height (remove height and overflow-y for page scroll), and LIFT / SINK in the script for how far the product rises and the backdrop sinks. */
  .w6prd { --w6prd-cream: #f3e7dc; --w6prd-clay: #b85a3a; --w6prd-ink: #3a1f16; --w6prd-accent: #a5492b;
    position: relative; height: 640px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; background: var(--w6prd-cream); color: var(--w6prd-ink); font-family: ui-sans-serif, system-ui, sans-serif; }
  .w6prd:focus-visible { outline: 2px solid var(--w6prd-accent); outline-offset: -2px; }
  .w6prd-hint { position: absolute; right: 16px; top: 16px; z-index: 2; padding: 6px 12px; border-radius: 999px; background: rgba(58,31,22,.85); color: var(--w6prd-cream); font-size: 12px; font-weight: 500; pointer-events: none; transition: opacity .5s ease; }
  .w6prd-moved .w6prd-hint { opacity: 0; }
  .w6prd-grid { max-width: 64rem; margin: 0 auto; padding: 40px 24px 64px; display: grid; gap: 40px; align-items: center; }
  @media (min-width: 768px) { .w6prd-grid { grid-template-columns: 1.1fr 1fr; padding-top: 48px; } }
  .w6prd-stage { position: relative; width: 100%; max-width: 420px; height: 500px; margin: 0 auto; }
  .w6prd-back { position: absolute; left: 16px; right: 16px; top: 40px; bottom: 0; border-radius: 999px 999px 0 0; background: var(--w6prd-clay); will-change: transform; }
  .w6prd-back span { position: absolute; left: 0; right: 0; top: 22%; text-align: center; font-size: 80px; font-weight: 600; line-height: 1; letter-spacing: -.02em; color: #cf7a58; }
  .w6prd-shadow { position: absolute; bottom: 24px; left: 50%; width: 224px; height: 40px; margin-left: -112px; border-radius: 50%; background: rgba(58,31,22,.4); filter: blur(24px); }
  .w6prd-card { position: absolute; left: 50%; top: 16%; width: 230px; margin-left: -115px; overflow: hidden; border-radius: 16px; background: #e7e5e2; box-shadow: 0 30px 60px -30px rgba(58,31,22,.7); will-change: transform; }
  .w6prd-card img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; }
  .w6prd-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--w6prd-accent); }
  .w6prd h2 { margin: 12px 0 0; font-size: 36px; line-height: 1.15; font-weight: 600; }
  .w6prd-lede { margin: 16px 0 0; max-width: 24rem; font-size: 16px; line-height: 1.6; color: #5c3a2d; }
  .w6prd ul { list-style: none; margin: 24px 0 0; padding: 24px 0 0; border-top: 1px solid rgba(58,31,22,.15); display: grid; gap: 12px; font-size: 14px; color: #5c3a2d; }
  .w6prd li { display: flex; gap: 12px; }
  .w6prd li::before { content: ""; flex-shrink: 0; width: 6px; height: 6px; margin-top: 7px; border-radius: 50%; background: var(--w6prd-accent); }
  .w6prd-ctas { display: flex; align-items: center; gap: 20px; margin-top: 32px; }
  .w6prd-btn { display: inline-flex; align-items: center; height: 48px; padding: 0 24px; border-radius: 999px; background: var(--w6prd-ink); color: var(--w6prd-cream); font-size: 14px; font-weight: 600; text-decoration: none; }
  .w6prd-btn:hover { background: #5a3326; }
  .w6prd-link { color: var(--w6prd-ink); font-size: 14px; font-weight: 500; text-underline-offset: 4px; }
  .w6prd-link:hover { color: var(--w6prd-accent); }
  .w6prd-btn:focus-visible, .w6prd-link:focus-visible { outline: 2px solid var(--w6prd-accent); outline-offset: 3px; }
  .w6prd-end { height: 360px; padding: 40px 24px 0; border-top: 1px solid rgba(58,31,22,.1); text-align: center; font-size: 14px; color: #6b4a3c; }
  @media (prefers-reduced-motion: reduce) { .w6prd-card, .w6prd-back { will-change: auto; } }
</style>
<script>
(function () {
  var box = document.querySelector(".w6prd");
  if (!box) return;
  var LIFT = 48, SINK = 28; // px the product rises and the backdrop sinks across the section
  var PAGE = false; // true = follow the page scroll (also remove height and overflow-y from .w6prd)
  var stage = box.querySelector(".w6prd-stage"), card = box.querySelector(".w6prd-card");
  var back = box.querySelector(".w6prd-back"), shadow = box.querySelector(".w6prd-shadow");
  var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
  var frame = 0, on = true;
  function draw() {
    frame = 0;
    box.classList.toggle("w6prd-moved", !PAGE && box.scrollTop > 8);
    if (reduce) return;
    var b = PAGE ? { top: 0, height: innerHeight } : box.getBoundingClientRect(), r = stage.getBoundingClientRect();
    var p = Math.max(-1, Math.min(1, (r.top + r.height / 2 - (b.top + b.height / 2)) / (b.height / 2 + r.height / 2)));
    var near = 1 - Math.abs(p);
    card.style.transform = "translate3d(0," + (p * LIFT).toFixed(1) + "px,0) scale(" + (0.96 + near * 0.04).toFixed(4) + ")";
    back.style.transform = "translate3d(0," + (-p * SINK).toFixed(1) + "px,0)";
    shadow.style.opacity = (0.35 + near * 0.65).toFixed(3); // the shadow deepens as the product settles
  }
  function req() { if (on && !frame) frame = requestAnimationFrame(draw); }
  new IntersectionObserver(function (e) { on = e[0].isIntersecting; if (on) req(); }).observe(box);
  (PAGE ? window : box).addEventListener("scroll", req, { passive: true });
  addEventListener("resize", req);
  req();
})();
</script>

With reduced motion: The product card rests centred over the arch with its full shadow and does not move.

Running cost: Two transforms and one opacity per scroll frame from a passive listener, paused when the section is off screen.

  • Set `LIFT` and `SINK` for how far the product rises and the backdrop sinks; small numbers look more expensive.
  • Recolour the arch with `--w6prd-clay` and change the number behind the product in the backdrop's span.
  • Swap the photo for your own; keep the 3 by 4 card so the layout holds.

Oversized Type Rows Sliding at Different Scroll Speeds

Three uppercase lines for a coffee roaster, each wider than the screen, drift sideways at their own pace and in alternating directions as you scroll. One line is cream, one a muted stone grey, one copper, so the difference in speed reads as layers of depth. The words sit offset at rest, which already looks composed before anyone scrolls.

<div class="w6typ" tabindex="0" role="region" aria-label="Ironbark Roasters, scrollable preview">
  <div class="w6typ-top"><p>Ironbark Roasters</p><span class="w6typ-hint" aria-hidden="true">Scroll inside</span></div>
  <h2 class="w6typ-sr">Roasted slow, ground to order, poured warm</h2>
  <div class="w6typ-rows" aria-hidden="true">
    <p class="w6typ-row" data-speed="-0.5" data-offset="40">Roasted slow</p>
    <p class="w6typ-row w6typ-outline" data-speed="0.32" data-offset="-260">Ground to order</p>
    <p class="w6typ-row w6typ-copper" data-speed="-0.18" data-offset="120">Poured warm</p>
  </div>
  <div class="w6typ-foot">
    <p>We roast twice a week in a converted tram shed and ship within a day, so the bag on your counter is never more than a week old.</p>
    <div class="w6typ-ctas"><a class="w6typ-btn" href="#">Start a subscription</a><a class="w6typ-link" href="#">Visit the tasting bar</a></div>
  </div>
  <div class="w6typ-end">Open Thursday to Sunday, eight until two.</div>
</div>
<style>
  /* Change these: colours, type size (font-size on .w6typ-row), and each row's data-speed (sideways px per px scrolled) and data-offset (starting shift). */
  .w6typ { --w6typ-bg: #1c1b19; --w6typ-paper: #f0e9dd; --w6typ-copper: #c9814a;
    position: relative; height: 600px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; background: var(--w6typ-bg); color: var(--w6typ-paper); font-family: ui-sans-serif, system-ui, sans-serif; }
  .w6typ:focus-visible { outline: 2px solid var(--w6typ-copper); outline-offset: -2px; }
  .w6typ-top { display: flex; align-items: center; justify-content: space-between; padding: 32px 24px 0; }
  .w6typ-top p { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .26em; text-transform: uppercase; color: #c9b8a2; }
  .w6typ-hint { padding: 6px 12px; border-radius: 999px; background: var(--w6typ-paper); color: var(--w6typ-bg); font-size: 12px; font-weight: 500; transition: opacity .5s ease; }
  .w6typ-moved .w6typ-hint { opacity: 0; }
  .w6typ-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .w6typ-rows { margin-top: 40px; }
  .w6typ-row { margin: 0 0 8px; white-space: nowrap; font-size: clamp(64px, 13vw, 184px); font-weight: 800; text-transform: uppercase; line-height: .92; letter-spacing: -.035em; will-change: transform; }
  .w6typ-outline { color: #6f675c; }
  .w6typ-copper { color: var(--w6typ-copper); }
  .w6typ-foot { max-width: 64rem; margin: 0 auto; padding: 56px 24px 80px; display: grid; gap: 32px; }
  .w6typ-foot > p { margin: 0; max-width: 28rem; font-size: 18px; line-height: 1.6; color: #d8cfc2; }
  .w6typ-ctas { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
  @media (min-width: 640px) { .w6typ-foot { grid-template-columns: 1fr 1fr; padding-left: 40px; padding-right: 40px; } .w6typ-ctas { align-items: flex-end; } .w6typ-top { padding: 32px 40px 0; } }
  .w6typ-btn { display: inline-flex; align-items: center; height: 48px; padding: 0 24px; border-radius: 999px; background: var(--w6typ-copper); color: var(--w6typ-bg); font-size: 14px; font-weight: 600; text-decoration: none; }
  .w6typ-btn:hover { background: #d99662; }
  .w6typ-link { color: var(--w6typ-paper); font-size: 14px; font-weight: 500; text-underline-offset: 4px; }
  .w6typ-link:hover { color: var(--w6typ-copper); }
  .w6typ-btn:focus-visible, .w6typ-link:focus-visible { outline: 2px solid var(--w6typ-paper); outline-offset: 3px; }
  .w6typ-end { height: 420px; padding: 40px 24px 0; border-top: 1px solid rgba(240,233,221,.1); font-size: 14px; color: #a99e8f; }
  @media (prefers-reduced-motion: reduce) { .w6typ-row { will-change: auto; } }
</style>
<script>
(function () {
  var box = document.querySelector(".w6typ");
  if (!box) return;
  var PAGE = false; // true = follow the page scroll (also remove height and overflow-y from .w6typ)
  var rows = [].slice.call(box.querySelectorAll(".w6typ-row"));
  var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
  var frame = 0, on = true;
  function draw() {
    frame = 0;
    var s = PAGE ? -box.getBoundingClientRect().top : box.scrollTop;
    box.classList.toggle("w6typ-moved", !PAGE && s > 8);
    rows.forEach(function (r) {
      var x = +r.getAttribute("data-offset") + (reduce ? 0 : s * r.getAttribute("data-speed"));
      r.style.transform = "translate3d(" + x.toFixed(1) + "px,0,0)";
    });
  }
  function req() { if (on && !frame) frame = requestAnimationFrame(draw); }
  new IntersectionObserver(function (e) { on = e[0].isIntersecting; if (on) req(); }).observe(box);
  (PAGE ? window : box).addEventListener("scroll", req, { passive: true });
  req();
})();
</script>

With reduced motion: The three lines rest at their staggered starting positions and do not slide.

Running cost: Three transforms per scroll frame from a passive listener, paused when the section is off screen.

  • Set each line's pace and direction with `data-speed` (or `speed` in `ROWS`); keep the fastest under about 0.6 so words stay readable.
  • Use `data-offset` to choose where each line rests before scrolling.
  • Retint the quiet middle line with the colour on `.w6typ-outline`; keep it darker than the others so it reads as further back.

Photo Cards Grid With Image Parallax Inside Frames

A two-column class listing for a pottery studio where each photo sits in a rounded frame slightly taller than it looks. As a card travels through the scroller, its photo slides the other way inside the frame, so the grid gains depth while the cards themselves keep to the normal scroll. The second column starts lower for a staggered rhythm, and on phones the cards stack into one column.

<div class="w6crd" tabindex="0" role="region" aria-label="Fernhill Clay Studio classes, scrollable preview">
  <div class="w6crd-hint" aria-hidden="true">Scroll inside</div>
  <div class="w6crd-wrap">
    <p class="w6crd-eyebrow">Fernhill Clay Studio</p>
    <div class="w6crd-head">
      <h2>Autumn classes at the wheel</h2>
      <p>Small groups of six, clay and firing included, aprons on the hook by the door.</p>
    </div>
    <ul class="w6crd-grid">
      <li><a class="w6crd-card" href="#"><div class="w6crd-frame"><img class="w6crd-img" src="https://images.pexels.com/photos/6611421/pexels-photo-6611421.jpeg?auto=compress&cs=tinysrgb&w=900" alt="Stacked handmade mugs and plates in pale and terracotta glazes on a studio shelf" width="900" height="675"></div><div class="w6crd-row"><h3>Wheel basics</h3><span>$240</span></div><p>Six Tuesday evenings</p></a></li>
      <li><a class="w6crd-card" href="#"><div class="w6crd-frame"><img class="w6crd-img" src="https://images.pexels.com/photos/7375048/pexels-photo-7375048.jpeg?auto=compress&cs=tinysrgb&w=900" alt="Unglazed ceramic mugs on a worktable beside brushes and small pots of glaze" width="900" height="675"></div><div class="w6crd-row"><h3>Glazing day</h3><span>$95</span></div><p>One Saturday, 10 to 4</p></a></li>
      <li><a class="w6crd-card" href="#"><div class="w6crd-frame"><img class="w6crd-img" src="https://images.pexels.com/photos/29286721/pexels-photo-29286721.jpeg?auto=compress&cs=tinysrgb&w=900" alt="A row of tall, unglazed clay vases drying on wooden boards in a workshop" width="900" height="675"></div><div class="w6crd-row"><h3>Tall forms</h3><span>$210</span></div><p>Four Thursday evenings</p></a></li>
      <li><a class="w6crd-card" href="#"><div class="w6crd-frame"><img class="w6crd-img" src="https://images.pexels.com/photos/8063803/pexels-photo-8063803.jpeg?auto=compress&cs=tinysrgb&w=900" alt="Rows of unfinished cream mugs waiting on shelves to be glazed" width="900" height="675"></div><div class="w6crd-row"><h3>Open studio</h3><span>$30</span></div><p>Any weekday afternoon</p></a></li>
    </ul>
  </div>
</div>
<style>
  /* Change these: box height (remove height and overflow for page scroll), paper and accent colours, and the extra photo height in .w6crd-img (top and height must match the SHIFT in the script). */
  .w6crd { --w6crd-paper: #f4efe6; --w6crd-ink: #2b2420; --w6crd-accent: #9a4a2c;
    position: relative; height: 620px; overflow-y: auto; overscroll-behavior: contain; background: var(--w6crd-paper); color: var(--w6crd-ink); font-family: ui-sans-serif, system-ui, sans-serif; }
  .w6crd:focus-visible { outline: 2px solid var(--w6crd-accent); outline-offset: -2px; }
  .w6crd-hint { position: absolute; right: 16px; top: 16px; padding: 6px 12px; border-radius: 999px; background: rgba(43,36,32,.8); color: var(--w6crd-paper); font-size: 12px; font-weight: 500; pointer-events: none; transition: opacity .5s ease; }
  .w6crd-moved .w6crd-hint { opacity: 0; }
  .w6crd-wrap { max-width: 64rem; margin: 0 auto; padding: 56px 20px 64px; }
  .w6crd-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--w6crd-accent); }
  .w6crd-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 12px; }
  .w6crd-head h2 { margin: 0; max-width: 28rem; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; font-weight: 600; }
  .w6crd-head p { margin: 0; max-width: 20rem; font-size: 14px; line-height: 1.6; color: #5b4c42; }
  .w6crd-grid { list-style: none; margin: 40px 0 0; padding: 0; display: grid; gap: 40px 24px; }
  @media (min-width: 640px) { .w6crd-grid { grid-template-columns: 1fr 1fr; } .w6crd-grid li:nth-child(even) { margin-top: 64px; } }
  .w6crd-card { display: block; border-radius: 8px; color: inherit; text-decoration: none; }
  .w6crd-card:hover h3 { text-decoration: underline; }
  .w6crd-card:focus-visible { outline: 2px solid var(--w6crd-accent); outline-offset: 6px; }
  .w6crd-frame { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 8px; background: #ddd2c2; box-shadow: 0 18px 40px -24px rgba(43,36,32,.6); }
  .w6crd-img { position: absolute; left: 0; top: -12%; width: 100%; height: 124%; object-fit: cover; will-change: transform; }
  .w6crd-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-top: 16px; }
  .w6crd-row h3 { margin: 0; font-size: 18px; font-weight: 600; }
  .w6crd-row span { font-size: 14px; font-weight: 600; color: var(--w6crd-accent); }
  .w6crd-card p { margin: 4px 0 0; font-size: 14px; color: #5b4c42; }
  @media (prefers-reduced-motion: reduce) { .w6crd-img { will-change: auto; } }
</style>
<script>
(function () {
  var box = document.querySelector(".w6crd");
  if (!box) return;
  var SHIFT = 9; // drift in % of the photo height; keep under the 12% of spare photo above and below
  var PAGE = false; // true = follow the page scroll (also remove height and overflow from .w6crd)
  var imgs = [].slice.call(box.querySelectorAll(".w6crd-img"));
  var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
  var frame = 0, on = true;
  function draw() {
    frame = 0;
    box.classList.toggle("w6crd-moved", !PAGE && box.scrollTop > 8);
    if (reduce) return;
    var b = PAGE ? { top: 0, height: innerHeight } : box.getBoundingClientRect(), c = b.top + b.height / 2;
    imgs.forEach(function (img) {
      var r = img.parentNode.getBoundingClientRect();
      var p = Math.max(-1, Math.min(1, (r.top + r.height / 2 - c) / (b.height / 2 + r.height / 2)));
      img.style.transform = "translate3d(0," + (-p * SHIFT).toFixed(2) + "%,0)";
    });
  }
  function req() { if (on && !frame) frame = requestAnimationFrame(draw); }
  new IntersectionObserver(function (e) { on = e[0].isIntersecting; if (on) req(); }).observe(box);
  (PAGE ? window : box).addEventListener("scroll", req, { passive: true });
  addEventListener("resize", req);
  req();
})();
</script>

With reduced motion: Each photo sits still and centred in its frame, so the grid reads as a plain card list.

Running cost: A passive scroll listener writes one transform per visible photo per frame and stops when the grid leaves the screen.

  • Change `SHIFT` to set the drift; keep it below the 12% of spare photo set by `top: -12%` and `height: 124%` on `.w6crd-img`.
  • Edit the `CLASSES` array (or each `li`) to swap titles, prices and photos; every photo keeps the 4 by 3 frame.
  • Recolour with `--w6crd-paper` and `--w6crd-accent`.

A print shop's landscape gallery laid out in three columns of portrait photos, where the middle column runs ahead of the scroll while the outer two lag slightly behind. The columns slide past each other like shelves at different distances, and the staggered start keeps the grid from looking like a table. Phones get two columns.

<div class="w6gal" tabindex="0" role="region" aria-label="Lowfield prints gallery, scrollable preview">
  <span class="w6gal-hint" aria-hidden="true">Scroll inside</span>
  <div class="w6gal-wrap">
    <p class="w6gal-eyebrow">Lowfield Prints</p>
    <h2>Quiet places, printed on cotton rag</h2>
    <div class="w6gal-grid">
      <ul class="w6gal-col" data-speed="0.12">
        <li><img src="https://images.pexels.com/photos/38826747/pexels-photo-38826747.jpeg?auto=compress&cs=tinysrgb&w=700" alt="A narrow dirt path running between tall green trees in a summer forest" width="700" height="933"></li>
        <li><img src="https://images.pexels.com/photos/34169529/pexels-photo-34169529.jpeg?auto=compress&cs=tinysrgb&w=700" alt="Green and black olives hanging from a silvery olive branch" width="700" height="933"></li>
        <li><img src="https://images.pexels.com/photos/27667695/pexels-photo-27667695.jpeg?auto=compress&cs=tinysrgb&w=700" alt="A turquoise mountain lake below steep grey peaks and a pine-covered shore" width="700" height="933"></li>
      </ul>
      <ul class="w6gal-col" data-speed="-0.22">
        <li><img src="https://images.pexels.com/photos/32100798/pexels-photo-32100798.jpeg?auto=compress&cs=tinysrgb&w=700" alt="A still alpine lake reflecting forest and pale rocky mountains" width="700" height="933"></li>
        <li><img src="https://images.pexels.com/photos/36962671/pexels-photo-36962671.jpeg?auto=compress&cs=tinysrgb&w=700" alt="A wildflower meadow full of pink clover and blue cornflowers" width="700" height="933"></li>
        <li><img src="https://images.pexels.com/photos/37291897/pexels-photo-37291897.jpeg?auto=compress&cs=tinysrgb&w=700" alt="Old stone cottages with slate roofs under a deep blue sky" width="700" height="933"></li>
      </ul>
      <ul class="w6gal-col" data-speed="0.04">
        <li><img src="https://images.pexels.com/photos/36494120/pexels-photo-36494120.jpeg?auto=compress&cs=tinysrgb&w=700" alt="Weathered blue fishing boats moored together in a harbour" width="700" height="933"></li>
        <li><img src="https://images.pexels.com/photos/14554019/pexels-photo-14554019.jpeg?auto=compress&cs=tinysrgb&w=700" alt="A leafy olive tree with ripe olives lit by sun" width="700" height="933"></li>
        <li><img src="https://images.pexels.com/photos/33311332/pexels-photo-33311332.jpeg?auto=compress&cs=tinysrgb&w=700" alt="A grassy path leading through a green orchard toward the trees" width="700" height="933"></li>
      </ul>
    </div>
  </div>
  <div class="w6gal-foot">
    <p>Every print is made to order in three sizes and signed on the back.</p>
    <a class="w6gal-btn" href="#">Browse all prints</a>
  </div>
</div>
<style>
  /* Change these: box height (remove height and overflow-y for page scroll), paper colour, the head start of the middle column (margin-top), and each column's data-speed. */
  .w6gal { --w6gal-paper: #efe9df; --w6gal-ink: #262019; --w6gal-accent: #7a5a3a;
    position: relative; height: 640px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; background: var(--w6gal-paper); color: var(--w6gal-ink); font-family: ui-sans-serif, system-ui, sans-serif; }
  .w6gal:focus-visible { outline: 2px solid var(--w6gal-accent); outline-offset: -2px; }
  .w6gal-hint { position: absolute; right: 16px; top: 16px; z-index: 1; padding: 6px 12px; border-radius: 999px; background: rgba(38,32,25,.85); color: var(--w6gal-paper); font-size: 12px; font-weight: 500; pointer-events: none; transition: opacity .5s ease; }
  .w6gal-moved .w6gal-hint { opacity: 0; }
  .w6gal-wrap, .w6gal-foot { max-width: 72rem; margin: 0 auto; padding: 48px 20px 0; }
  .w6gal-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--w6gal-accent); }
  .w6gal h2 { margin: 12px 0 0; max-width: 32rem; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; font-weight: 600; }
  .w6gal-grid { margin-top: 40px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .w6gal-col { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; align-content: start; will-change: transform; }
  .w6gal-col:nth-child(2) { margin-top: 64px; }
  .w6gal-col:nth-child(3) { display: none; }
  @media (min-width: 640px) { .w6gal-grid { grid-template-columns: repeat(3, 1fr); gap: 24px; } .w6gal-col { gap: 24px; } .w6gal-col:nth-child(3) { display: grid; } .w6gal-wrap, .w6gal-foot { padding-left: 32px; padding-right: 32px; } }
  .w6gal-col li { aspect-ratio: 3 / 4; overflow: hidden; border-radius: 6px; background: #d9cfbf; box-shadow: 0 16px 32px -20px rgba(38,32,25,.55); }
  .w6gal-col img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .w6gal-foot { margin-top: 96px; padding-top: 32px; padding-bottom: 64px; border-top: 1px solid rgba(38,32,25,.15); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
  .w6gal-foot p { margin: 0; max-width: 28rem; font-size: 14px; line-height: 1.6; color: #5a4f43; }
  .w6gal-btn { display: inline-flex; align-items: center; height: 44px; padding: 0 24px; border-radius: 999px; background: var(--w6gal-ink); color: var(--w6gal-paper); font-size: 14px; font-weight: 600; text-decoration: none; }
  .w6gal-btn:hover { background: #3d3329; }
  .w6gal-btn:focus-visible { outline: 2px solid var(--w6gal-ink); outline-offset: 3px; }
  @media (prefers-reduced-motion: reduce) { .w6gal-col { will-change: auto; } }
</style>
<script>
(function () {
  var box = document.querySelector(".w6gal");
  if (!box) return;
  var PAGE = false; // true = follow the page scroll (also remove height and overflow-y from .w6gal)
  var cols = [].slice.call(box.querySelectorAll(".w6gal-col"));
  var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
  var frame = 0, on = true;
  function draw() {
    frame = 0;
    var s = PAGE ? -box.getBoundingClientRect().top : box.scrollTop;
    box.classList.toggle("w6gal-moved", !PAGE && s > 8);
    if (reduce) return;
    cols.forEach(function (c) {
      c.style.transform = "translate3d(0," + (s * c.getAttribute("data-speed")).toFixed(1) + "px,0)";
    });
  }
  function req() { if (on && !frame) frame = requestAnimationFrame(draw); }
  new IntersectionObserver(function (e) { on = e[0].isIntersecting; if (on) req(); }).observe(box);
  (PAGE ? window : box).addEventListener("scroll", req, { passive: true });
})();
</script>

With reduced motion: The columns keep their staggered starting layout and scroll together as one grid.

Running cost: Three column transforms per scroll frame from a passive listener; nothing runs while the gallery is off screen.

  • Change each column's `data-speed` (or `speed` in `COLUMNS`); values between -0.3 and 0.2 keep the columns from drifting apart.
  • Adjust the middle column's `margin-top` to change the stagger at rest.
  • Swap photos in each list; keep a shared `aspect-ratio` so the columns stay even.

Scroll Snap Full Height Sections With Gentle Parallax

A three-stop desert journey where each full-height section snaps into place with CSS scroll snapping, and the photo inside each one drifts a little against the frame as it arrives and leaves. The snapping is native, so wheel, keys and touch all land cleanly on a section. Captions sit low over a warm shade for contrast on any photo.

<div class="w6snp" tabindex="0" role="region" aria-label="Erg Saffa desert journey, scrollable preview">
  <section class="w6snp-stop">
    <img class="w6snp-img" src="https://images.pexels.com/photos/35972428/pexels-photo-35972428.jpeg?auto=compress&cs=tinysrgb&w=1600" alt="Golden sand dunes rolling under a clear blue sky" width="1600" height="1067">
    <div class="w6snp-shade" aria-hidden="true"></div>
    <p class="w6snp-brand">Erg Saffa Camps</p>
    <span class="w6snp-hint" aria-hidden="true">Scroll inside</span>
    <div class="w6snp-copy">
      <p class="w6snp-num">01 / 03</p>
      <h2>Arrive at the edge</h2>
      <p>The road ends at the last well. From there it is camels, or your own feet, for the final hour in.</p>
    </div>
  </section>
  <section class="w6snp-stop">
    <img class="w6snp-img" src="https://images.pexels.com/photos/2563810/pexels-photo-2563810.jpeg?auto=compress&cs=tinysrgb&w=1600" alt="Close view of wind ripples across a soft grey-gold dune" width="1600" height="1067">
    <div class="w6snp-shade" aria-hidden="true"></div>
    <div class="w6snp-copy">
      <p class="w6snp-num">02 / 03</p>
      <h2>Walk the ridges</h2>
      <p>Mornings start before the heat, along the dune crests, with a guide who reads the sand like a map.</p>
    </div>
  </section>
  <section class="w6snp-stop">
    <img class="w6snp-img" src="https://images.pexels.com/photos/2504713/pexels-photo-2504713.jpeg?auto=compress&cs=tinysrgb&w=1600" alt="Long dunes with ripple patterns running down to a calm sea at dusk" width="1600" height="1067">
    <div class="w6snp-shade" aria-hidden="true"></div>
    <div class="w6snp-copy">
      <p class="w6snp-num">03 / 03</p>
      <h2>Sleep by the water</h2>
      <p>The last camp sits where the dunes meet the sea. Dinner is cooked on coals and served on the sand.</p>
      <a class="w6snp-btn" href="#">See spring departures</a>
    </div>
  </section>
</div>
<style>
  /* Change these: --w6snp-h (box and section height; use 100vh and drop overflow for a full page), the shade gradient, and SHIFT in the script. Use proximity instead of mandatory for softer snapping. */
  .w6snp { --w6snp-h: 600px; --w6snp-sand: #f3e3c7; --w6snp-dark: #2a1d14;
    position: relative; height: var(--w6snp-h); overflow-y: auto; overscroll-behavior: contain; scroll-snap-type: y mandatory; background: var(--w6snp-dark); color: #fff; font-family: ui-sans-serif, system-ui, sans-serif; }
  .w6snp:focus-visible { outline: 2px solid var(--w6snp-sand); outline-offset: -2px; }
  .w6snp-stop { position: relative; height: var(--w6snp-h); overflow: hidden; scroll-snap-align: start; }
  .w6snp-img { position: absolute; left: 0; top: -10%; width: 100%; height: 120%; object-fit: cover; will-change: transform; }
  .w6snp-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(29,19,12,.85), rgba(29,19,12,.15) 50%, rgba(29,19,12,.4)); }
  .w6snp-brand { position: absolute; left: 24px; top: 32px; margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .28em; text-transform: uppercase; color: var(--w6snp-sand); }
  .w6snp-hint { position: absolute; right: 16px; top: 24px; padding: 6px 12px; border-radius: 999px; background: var(--w6snp-sand); color: var(--w6snp-dark); font-size: 12px; font-weight: 500; pointer-events: none; transition: opacity .5s ease; }
  .w6snp-moved .w6snp-hint { opacity: 0; }
  .w6snp-copy { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 24px 48px; }
  @media (min-width: 640px) { .w6snp-copy { padding: 0 48px 48px; } .w6snp-brand { left: 48px; } }
  .w6snp-num { margin: 0; font-size: 14px; font-weight: 600; color: var(--w6snp-sand); font-variant-numeric: tabular-nums; }
  .w6snp-copy h2 { margin: 8px 0 0; font-size: clamp(36px, 5vw, 48px); line-height: 1.15; font-weight: 600; }
  .w6snp-copy p:not(.w6snp-num) { margin: 12px 0 0; max-width: 28rem; font-size: 16px; line-height: 1.6; color: #efe6d8; }
  .w6snp-btn { margin-top: 24px; display: inline-flex; align-items: center; height: 48px; padding: 0 24px; border-radius: 999px; background: var(--w6snp-sand); color: var(--w6snp-dark); font-size: 14px; font-weight: 600; text-decoration: none; }
  .w6snp-btn:hover { background: #fff; }
  .w6snp-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
  @media (prefers-reduced-motion: reduce) { .w6snp-img { will-change: auto; } }
</style>
<script>
(function () {
  var box = document.querySelector(".w6snp");
  if (!box) return;
  var SHIFT = 8; // drift as a percentage of the photo height; keep under the 10 percent of spare photo
  var imgs = [].slice.call(box.querySelectorAll(".w6snp-img"));
  var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
  var frame = 0, on = true;
  function draw() {
    frame = 0;
    box.classList.toggle("w6snp-moved", box.scrollTop > 8);
    if (reduce) return;
    var h = box.clientHeight || 1;
    imgs.forEach(function (img, i) {
      var p = Math.max(-1, Math.min(1, (i * h - box.scrollTop) / h)); // 0 when this section fills the box
      img.style.transform = "translate3d(0," + (p * SHIFT).toFixed(2) + "%,0)";
    });
  }
  function req() { if (on && !frame) frame = requestAnimationFrame(draw); }
  new IntersectionObserver(function (e) { on = e[0].isIntersecting; if (on) req(); }).observe(box);
  box.addEventListener("scroll", req, { passive: true });
  req();
})();
</script>

With reduced motion: Sections still snap into place, but each photo stays fixed and centred in its frame.

Running cost: Snapping is native CSS; a passive listener writes three transforms per scroll frame and idles off screen.

  • Switch `scroll-snap-type: y mandatory` to `y proximity` if sections hold more text than fits in one screen.
  • Change `SHIFT` for more or less drift; keep it under the 10% of spare photo set by `top: -10%`.
  • Set `--w6snp-h` to `100vh` when the sections should fill the window.

Sticky Photo Backdrop With Cards Passing Over

A walking holiday itinerary where a coastal photo stays pinned with position: sticky while four day cards scroll up across it. The photo also eases from a slight zoom to its natural size as you go, so the backdrop feels alive without moving sideways. It gives the fixed-background look without background-attachment: fixed, and on phones the cards take the full width.

<div class="w6stk" tabindex="0" role="region" aria-label="Fernmouth coast walk, scrollable preview">
  <div class="w6stk-back">
    <img class="w6stk-photo" src="https://images.pexels.com/photos/7694094/pexels-photo-7694094.jpeg?auto=compress&cs=tinysrgb&w=1600" alt="A rocky headland with dry grass and dark green trees above a wide grey sea under cloud" width="1600" height="1280">
    <div class="w6stk-shade" aria-hidden="true"></div>
    <div class="w6stk-copy">
      <p class="w6stk-eyebrow">Fernmouth Coast Walks</p>
      <h2>Four days on the south coast path</h2>
      <p>Self-guided, with bags carried between inns. The cliffs stay put while the days go by.</p>
    </div>
    <span class="w6stk-hint" aria-hidden="true">Scroll inside</span>
  </div>
  <ol class="w6stk-cards">
    <li><div class="w6stk-meta"><span>Day one</span><span>11 km</span></div><h3>Harbour to the lighthouse</h3><p>A level start along the sea wall, then a gentle climb to the lamp room for the first long view of the bay.</p></li>
    <li><div class="w6stk-meta"><span>Day two</span><span>16 km</span></div><h3>The red cliffs</h3><p>The wildest stretch: open headland, a lot of sky, and a lunch stop above the cove where seals haul out.</p></li>
    <li><div class="w6stk-meta"><span>Day three</span><span>13 km</span></div><h3>Through the oak combe</h3><p>The path drops inland into shade, crosses two footbridges and climbs back out to a farm tea room.</p></li>
    <li><div class="w6stk-meta"><span>Day four</span><span>8 km</span></div><h3>Down to Pellow Sands</h3><p>An easy final morning that ends on a wide beach, with your bags already waiting at the station hotel.</p></li>
    <li class="w6stk-last"><a class="w6stk-btn" href="#">Choose your start date</a></li>
  </ol>
</div>
<style>
  /* Change these: --w6stk-h (box and backdrop height; for page scroll set it to 100vh and remove overflow), --w6stk-gap (how much backdrop shows before the first card), colours. ZOOM in the script sets the slow ease-out of the photo. */
  .w6stk { --w6stk-h: 620px; --w6stk-gap: 360px; --w6stk-navy: #0f1b2a; --w6stk-sand: #e9dcc4;
    position: relative; height: var(--w6stk-h); overflow-y: auto; overscroll-behavior: contain; background: var(--w6stk-navy); font-family: ui-sans-serif, system-ui, sans-serif; }
  .w6stk:focus-visible { outline: 2px solid var(--w6stk-sand); outline-offset: -2px; }
  .w6stk-back { position: sticky; top: 0; height: var(--w6stk-h); overflow: hidden; }
  .w6stk-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.1); transform-origin: 50% 40%; will-change: transform; }
  .w6stk-shade { position: absolute; inset: 0; background: linear-gradient(rgba(15,27,42,.8), rgba(15,27,42,.3) 50%, rgba(15,27,42,.85)); }
  .w6stk-copy { position: relative; padding: 48px 24px 0; }
  .w6stk-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .26em; text-transform: uppercase; color: var(--w6stk-sand); }
  .w6stk-copy h2 { margin: 12px 0 0; max-width: 32rem; font-size: clamp(36px, 5vw, 48px); line-height: 1.15; font-weight: 600; color: #fff; }
  .w6stk-copy p:not(.w6stk-eyebrow) { margin: 16px 0 0; max-width: 24rem; font-size: 16px; line-height: 1.6; color: #dfe6ee; }
  .w6stk-hint { position: absolute; right: 16px; top: 16px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.9); color: var(--w6stk-navy); font-size: 12px; font-weight: 500; pointer-events: none; transition: opacity .5s ease; }
  .w6stk-moved .w6stk-hint { opacity: 0; }
  .w6stk-cards { position: relative; list-style: none; margin: calc(var(--w6stk-h) * -1) 0 0; padding: var(--w6stk-gap) 20px 64px; display: grid; gap: 20px; }
  @media (min-width: 640px) { .w6stk-cards { max-width: 28rem; margin-left: auto; padding-left: 40px; padding-right: 40px; } .w6stk-copy { padding: 48px 48px 0; } }
  .w6stk-cards li:not(.w6stk-last) { padding: 24px; border-radius: 12px; background: #f6f1e7; color: #13202f; box-shadow: 0 24px 48px -20px rgba(0,0,0,.6); }
  .w6stk-meta { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: #5a6675; }
  .w6stk-cards h3 { margin: 8px 0 0; font-size: 20px; font-weight: 600; }
  .w6stk-cards p { margin: 8px 0 0; font-size: 14px; line-height: 1.6; color: #3c4756; }
  .w6stk-btn { display: flex; align-items: center; justify-content: center; height: 48px; border-radius: 12px; background: var(--w6stk-sand); color: var(--w6stk-navy); font-size: 14px; font-weight: 600; text-decoration: none; }
  .w6stk-btn:hover { background: #fff; }
  .w6stk-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
  @media (prefers-reduced-motion: reduce) { .w6stk-photo { transform: none; will-change: auto; } }
</style>
<script>
(function () {
  var box = document.querySelector(".w6stk");
  if (!box) return;
  var ZOOM = 0.1; // the photo eases from scale 1 + ZOOM down to 1 across the scroll
  var photo = box.querySelector(".w6stk-photo");
  var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
  var frame = 0, on = true;
  function draw() {
    frame = 0;
    box.classList.toggle("w6stk-moved", box.scrollTop > 8);
    if (reduce) return;
    var m = box.scrollHeight - box.clientHeight, p = m ? box.scrollTop / m : 0;
    photo.style.transform = "scale(" + (1 + ZOOM * (1 - p)).toFixed(4) + ")";
  }
  function req() { if (on && !frame) frame = requestAnimationFrame(draw); }
  new IntersectionObserver(function (e) { on = e[0].isIntersecting; if (on) req(); }).observe(box);
  box.addEventListener("scroll", req, { passive: true });
  req();
})();
</script>

With reduced motion: The photo stays at its natural size and the cards still scroll over it.

Running cost: Sticky positioning is handled by the browser; the script only writes one scale per scroll frame and stops off screen.

  • Change `--w6stk-gap` to show more or less of the backdrop and title before the first card arrives.
  • Set `ZOOM` to 0 for a perfectly still photo, or 0.2 for a stronger ease-out.
  • Swap the photo and adjust the shade gradient on `.w6stk-shade` so the title keeps its contrast.

Performance notes

Every layer here moves with transform only, inside a box with overflow clipped, so the page layout never changes while scrolling. In browsers with scroll-driven animations the movement runs off the main thread; elsewhere, a single passive listener writes transforms once per frame while the section is visible.

background-attachment: fixed is avoided on purpose: it is ignored on iOS and forces a repaint of the whole background on many desktop browsers. Large parallax images are given explicit dimensions so they never shift the layout as they load.

Questions

How do I make a parallax scrolling effect with CSS?

Give a background layer a scroll-driven animation that translates it a short distance across the section's view() timeline, so it moves less than the content in front. Where that is unsupported, a small script can compute the same translate from the section's position.

Is scroll-behavior: smooth supported everywhere?

Yes. MDN lists it in Chrome, Edge, Firefox and Safari, with Safari support since 15.4. Browsers also skip the easing when the visitor has asked for reduced motion if you set it inside a prefers-reduced-motion: no-preference query, as these snippets do.

Do I need a smooth scroll library?

For eased anchor jumps, no. Libraries mainly add inertia to wheel scrolling and sync it with animations. If you want that feel in one area, the container version here does it in a few lines; site-wide, weigh it against people who find delayed scrolling uncomfortable.

Does parallax work on phones?

Transform-based parallax does, because it does not rely on fixed backgrounds. Keep the effect smaller on narrow screens, where layers have less room to move, and let reduced motion turn it off.

More collections: Scroll Animations Without a Library, Stacking Cards on Scroll, Custom Cursor Effects in CSS and JavaScript. All scroll effects. Build your site free to have a full site built around them.

Product

Who It's For

Features

Resources

Company

View Sitemap