Expanding Cards and Image Panels
Updated 2026-10-15. 8 effects.
Expanding cards show a row of narrow image panels; the chosen one widens to reveal its photo and caption while the others shrink. Animating flex-grow causes layout work on every frame, so the versions here slide full-size layers with transforms instead, and open on hover, keyboard focus or tap alike.
Panels work when every item has a strong picture and a short label: destinations, collections, rooms, team members or product colours. Four to six panels fit a desktop row; on phones the same markup turns into a vertical stack where tapping a strip opens it.
Decide whether a panel opens on hover or only on click. Hover feels quick on a mouse but can open panels by accident as the pointer crosses the row; click or tap is calmer and is the only option on touch. Several effects here let you switch with one setting.
Compare them
| Effect | Built with | Size (gzipped) | Running cost | Browser support |
|---|---|---|---|---|
| Auto Cycling Expanding Flower Panels That Pause | CSS and a small script | 3.4 KB | The timer is a CSS animation on one thin bar, paused off screen, with a class change every few seconds. | All current browsers |
| Expanding Bread Recipe Step Panels With Notes | CSS and a small script | 3.3 KB | Each step change animates transforms and opacity on four panels and then the page is idle. | All current browsers |
| Expanding Class Panels as Keyboard Tabs | CSS and a small script | 3.3 KB | Selecting a tab moves a handful of layers with transforms and fades one panel in; it is idle otherwise. | All current browsers |
| Expanding Product Colourway Panels With Swatches | CSS and a small script | 3.2 KB | A few transforms and one opacity fade per change, with no work while nothing is being chosen. | All current browsers |
| Expanding Team Portrait Panels With Bios | CSS and a small script | 3.2 KB | Opening a portrait changes transforms and opacity on four layers; there is no loop or scroll work. | All current browsers |
| Expanding Travel Destination Photo Panels | CSS and a small script | 3.2 KB | Only transforms and opacity change when a panel opens, and nothing runs between interactions. | All current browsers |
| Interior Room Gallery With Captions After Settle | CSS and a small script | 3.3 KB | One class change per choice moves the cards with transforms, and a single transitionend listener reveals the caption. | All current browsers |
| Vertical Photo Strip Accordion for Trail Guides | CSS and a small script | 3.1 KB | A row change moves four layers with transforms and fades two overlays; nothing runs in between. | All current browsers |
Auto Cycling Expanding Flower Panels That Pause
A florist's weekly bunches shown as photo panels that open one after another by themselves, with a fine bar under each caption counting down to the next. The moment a visitor points at a panel, tabs into it or taps it, the slideshow stops and stays on their choice. A Pause and Play button sits above, and phones stack the panels.
<section class="w5cyc-root w5cyc">
<div class="w5cyc-wrap">
<div class="w5cyc-head">
<div><p class="w5cyc-eyebrow">Ashby Flower Room</p><h2 class="w5cyc-h2">This week’s bunches</h2></div>
<button type="button" class="w5cyc-toggle">Pause slideshow</button>
</div>
<div class="w5cyc-stage is-auto" style="--dur:3000ms">
<div class="w5cyc-panel is-open" style="--i:0">
<div class="w5cyc-media"><img src="https://images.pexels.com/photos/38551722/pexels-photo-38551722.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A hand-tied bunch of red gerberas, pale roses and purple asters" loading="eager"><div class="w5cyc-shade"></div><div class="w5cyc-dim"></div></div>
<div class="w5cyc-tab" aria-hidden="true"><span class="w5cyc-num">01</span><span class="w5cyc-name">The Garden Party</span><span class="w5cyc-dot"></span></div>
<button type="button" class="w5cyc-hit" aria-expanded="true"><span class="w5cyc-sr">The Garden Party, $64</span></button>
<div class="w5cyc-cap"><h3>The Garden Party</h3><p class="w5cyc-stems">Gerberas, pale roses, asters · $64</p><a href="#">Order for Friday</a><span class="w5cyc-track" aria-hidden="true"><span class="w5cyc-fill"></span></span></div>
</div>
<div class="w5cyc-panel is-after" style="--i:1">
<div class="w5cyc-media"><img src="https://images.pexels.com/photos/20491660/pexels-photo-20491660.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Tightly packed red and white tulips seen from above" loading="lazy"><div class="w5cyc-shade"></div><div class="w5cyc-dim"></div></div>
<div class="w5cyc-tab" aria-hidden="true"><span class="w5cyc-num">02</span><span class="w5cyc-name">Tulip Bundle</span><span class="w5cyc-dot"></span></div>
<button type="button" class="w5cyc-hit" aria-expanded="false"><span class="w5cyc-sr">Tulip Bundle, $42</span></button>
<div class="w5cyc-cap"><h3>Tulip Bundle</h3><p class="w5cyc-stems">Forty red and white tulips · $42</p><a href="#" tabindex="-1">Order for Friday</a><span class="w5cyc-track" aria-hidden="true"><span class="w5cyc-fill"></span></span></div>
</div>
<div class="w5cyc-panel is-after" style="--i:2">
<div class="w5cyc-media"><img src="https://images.pexels.com/photos/34658018/pexels-photo-34658018.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Orange chrysanthemums, roses, small chillies and berries in a bright mix" loading="lazy"><div class="w5cyc-shade"></div><div class="w5cyc-dim"></div></div>
<div class="w5cyc-tab" aria-hidden="true"><span class="w5cyc-num">03</span><span class="w5cyc-name">Market Armful</span><span class="w5cyc-dot"></span></div>
<button type="button" class="w5cyc-hit" aria-expanded="false"><span class="w5cyc-sr">Market Armful, $78</span></button>
<div class="w5cyc-cap"><h3>Market Armful</h3><p class="w5cyc-stems">Chrysanthemums, roses, berries · $78</p><a href="#" tabindex="-1">Order for Friday</a><span class="w5cyc-track" aria-hidden="true"><span class="w5cyc-fill"></span></span></div>
</div>
<div class="w5cyc-panel is-after" style="--i:3">
<div class="w5cyc-media"><img src="https://images.pexels.com/photos/36399737/pexels-photo-36399737.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Pink peonies wrapped in black paper on a dark table" loading="lazy"><div class="w5cyc-shade"></div><div class="w5cyc-dim"></div></div>
<div class="w5cyc-tab" aria-hidden="true"><span class="w5cyc-num">04</span><span class="w5cyc-name">Peony Wrap</span><span class="w5cyc-dot"></span></div>
<button type="button" class="w5cyc-hit" aria-expanded="false"><span class="w5cyc-sr">Peony Wrap, $85</span></button>
<div class="w5cyc-cap"><h3>Peony Wrap</h3><p class="w5cyc-stems">Pink peonies in black paper · $85</p><a href="#" tabindex="-1">Order for Friday</a><span class="w5cyc-track" aria-hidden="true"><span class="w5cyc-fill"></span></span></div>
</div>
<div class="w5cyc-panel is-after" style="--i:4">
<div class="w5cyc-media"><img src="https://images.pexels.com/photos/31046064/pexels-photo-31046064.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Dried flowers in red, blue and orange standing against a dark wall" loading="lazy"><div class="w5cyc-shade"></div><div class="w5cyc-dim"></div></div>
<div class="w5cyc-tab" aria-hidden="true"><span class="w5cyc-num">05</span><span class="w5cyc-name">Dried Ember</span><span class="w5cyc-dot"></span></div>
<button type="button" class="w5cyc-hit" aria-expanded="false"><span class="w5cyc-sr">Dried Ember, $56</span></button>
<div class="w5cyc-cap"><h3>Dried Ember</h3><p class="w5cyc-stems">Dried grasses and everlasting flowers · $56</p><a href="#" tabindex="-1">Order for Friday</a><span class="w5cyc-track" aria-hidden="true"><span class="w5cyc-fill"></span></span></div>
</div>
</div>
<p class="w5cyc-sr" aria-live="polite"></p>
</div>
</section>
<style>
/* Change these: --dur on .w5cyc-stage is how long each bunch stays open,
--c the closed strip width, --n the number of panels, and the stage height. */
.w5cyc { background: #161512; padding: 56px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #f3ece0; }
.w5cyc-wrap { max-width: 1152px; margin: 0 auto; }
.w5cyc-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 32px; }
.w5cyc-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: #e3b7a3; }
.w5cyc-h2 { margin: 12px 0 0; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(30px, 4vw, 36px); font-weight: 400; }
.w5cyc-toggle { height: 44px; padding: 0 20px; border: 1px solid #5b544a; border-radius: 999px; background: transparent; color: #f3ece0; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.w5cyc-toggle:hover { border-color: #e3b7a3; }
.w5cyc-toggle:focus-visible { outline: 2px solid #e3b7a3; outline-offset: 3px; }
.w5cyc-num { font-size: 12px; font-weight: 600; }
.w5cyc-dot { width: 6px; height: 6px; border-radius: 999px; background: #e3b7a3; }
.w5cyc-cap h3 { margin: 0; font-family: Georgia, 'Times New Roman', serif; font-size: 30px; line-height: 1.15; font-weight: 400; }
.w5cyc-stems { margin: 8px 0 0; font-size: 14px; color: #d9d0c2; }
.w5cyc-cap a { display: inline-flex; align-items: center; height: 40px; margin-top: 20px; padding: 0 20px; border-radius: 999px; background: #f3ece0; color: #161512; font-size: 14px; font-weight: 600; text-decoration: none; }
.w5cyc-cap a:hover { background: #fff; }
.w5cyc-cap a:focus-visible { outline: 2px solid #e3b7a3; outline-offset: 3px; }
.w5cyc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.w5cyc-stage{--c:72px;--n:5;--ow:calc(100% - (var(--n) - 1) * var(--c));position:relative;height:540px;overflow:hidden;border-radius:4px;background:#0d0c0a}
.w5cyc-panel{position:absolute;inset:0;z-index:var(--i);transform:translateX(calc(var(--i) * var(--c)));transition:transform .9s cubic-bezier(.65,0,.25,1);box-shadow:-14px 0 30px rgba(0,0,0,.5)}
.w5cyc-panel.is-after{transform:translateX(calc(100% - (var(--n) - var(--i)) * var(--c)))}
.w5cyc-media{position:absolute;top:0;left:0;bottom:0;width:var(--ow);overflow:hidden;background:#24211c}
.w5cyc-media img{display:block;width:100%;height:100%;object-fit:cover;transform:translateX(calc(var(--c) / 2 - 50%)) scale(1.12);transition:transform 1.2s cubic-bezier(.65,0,.25,1)}
.is-open .w5cyc-media img{transform:scale(1.02)}
.w5cyc-shade{position:absolute;inset:0;background:linear-gradient(to top,rgba(13,12,10,.9),rgba(13,12,10,.1) 50%,rgba(13,12,10,0))}
.w5cyc-dim{position:absolute;inset:0;background:rgba(13,12,10,.55);transition:opacity .6s}
.is-open .w5cyc-dim{opacity:0}
.w5cyc-tab{position:absolute;top:0;left:0;bottom:0;width:var(--c);display:flex;flex-direction:column;align-items:center;justify-content:space-between;padding:24px 0;box-sizing:border-box;color:#f3ece0;pointer-events:none;transition:opacity .3s}
.is-open .w5cyc-tab{opacity:0}
.w5cyc-name{writing-mode:vertical-rl;transform:rotate(180deg);font-family:Georgia,'Times New Roman',serif;font-size:17px;white-space:nowrap}
.w5cyc-cap{position:absolute;left:0;bottom:0;width:var(--ow);box-sizing:border-box;padding:34px;color:#f3ece0;opacity:0;transform:translateY(14px);transition:opacity .3s,transform .3s;pointer-events:none}
.is-open .w5cyc-cap{opacity:1;transform:none;transition:opacity .6s .4s,transform .7s .4s cubic-bezier(.22,1,.36,1)}
.w5cyc-cap a{pointer-events:auto}
.w5cyc-track{display:block;width:160px;height:2px;margin-top:22px;background:rgba(243,236,224,.25);overflow:hidden;opacity:0;transition:opacity .3s}
.w5cyc-fill{display:block;height:100%;background:#e3b7a3;transform:scaleX(0);transform-origin:0 50%}
.is-auto .is-open .w5cyc-track{opacity:1}
.is-auto .is-open .w5cyc-fill{animation:w5cyc-fill var(--dur) linear forwards}
.w5cyc-root[data-paused] .w5cyc-fill{animation-play-state:paused}
@keyframes w5cyc-fill{to{transform:scaleX(1)}}
.w5cyc-hit{position:absolute;top:0;left:0;bottom:0;width:var(--c);padding:0;border:0;background:transparent;cursor:pointer}
.is-open .w5cyc-hit{width:var(--ow);cursor:default}
.w5cyc-hit:focus-visible{outline:3px solid #e3b7a3;outline-offset:-7px}
@media (max-width:640px){
.w5cyc-stage{--c:56px;height:600px}
.w5cyc-panel{transform:translateY(calc(var(--i) * var(--c)));box-shadow:0 -14px 30px rgba(0,0,0,.5)}
.w5cyc-panel.is-after{transform:translateY(calc(100% - (var(--n) - var(--i)) * var(--c)))}
.w5cyc-media{right:0;bottom:auto;width:auto;height:var(--ow)}
.w5cyc-media img{transform:translateY(calc(var(--c) / 2 - 50%)) scale(1.12)}
.w5cyc-tab{right:0;bottom:auto;width:auto;height:var(--c);flex-direction:row;padding:0 20px}
.w5cyc-name{writing-mode:horizontal-tb;transform:none}
.w5cyc-cap{width:auto;right:0;bottom:calc((var(--n) - 1) * var(--c));padding:22px}
.w5cyc-hit{right:0;bottom:auto;width:auto;height:var(--c)}
.is-open .w5cyc-hit{width:auto;height:var(--ow)}
}
@media (prefers-reduced-motion:reduce){.w5cyc-panel,.w5cyc-media img,.w5cyc-dim,.w5cyc-tab,.w5cyc-cap,.is-open .w5cyc-cap{transition:none}.w5cyc-track{display:none}}
</style>
<script>
(function () {
/* Change this: how long (ms) the mouse rests on a strip before it opens. */
var HOVER_DELAY = 80;
var root = document.querySelector(".w5cyc");
if (!root) return;
var stage = root.querySelector(".w5cyc-stage"), btn = root.querySelector(".w5cyc-toggle"), live = root.querySelector("[aria-live]");
var panels = [].slice.call(root.querySelectorAll(".w5cyc-panel")), cur = 0, timer = 0, auto = true;
function open(k) {
cur = k;
panels.forEach(function (p, i) {
p.classList.toggle("is-open", i === k);
p.classList.toggle("is-after", i > k);
p.querySelector(".w5cyc-hit").setAttribute("aria-expanded", i === k ? "true" : "false");
p.querySelector(".w5cyc-cap a").tabIndex = i === k ? 0 : -1;
});
if (!auto) live.textContent = "Showing " + panels[k].querySelector("h3").textContent;
}
function setAuto(on) {
auto = on;
stage.classList.toggle("is-auto", on);
btn.textContent = on ? "Pause slideshow" : "Play slideshow";
}
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) { setAuto(false); btn.hidden = true; }
btn.addEventListener("click", function () { setAuto(!auto); });
stage.addEventListener("animationend", function (e) {
if (auto && e.target.classList.contains("w5cyc-fill")) open((cur + 1) % panels.length);
});
stage.addEventListener("focusin", function () { setAuto(false); });
new IntersectionObserver(function (en) {
if (en[0].isIntersecting) root.removeAttribute("data-paused"); else root.setAttribute("data-paused", "");
}).observe(root);
panels.forEach(function (p, i) {
var b = p.querySelector(".w5cyc-hit");
b.addEventListener("pointerenter", function (e) {
if (e.pointerType !== "mouse") return;
setAuto(false);
clearTimeout(timer);
timer = setTimeout(function () { open(i); }, HOVER_DELAY);
});
b.addEventListener("pointerleave", function () { clearTimeout(timer); });
b.addEventListener("focus", function () { setAuto(false); open(i); });
b.addEventListener("click", function () { setAuto(false); open(i); });
});
})();
</script>
With reduced motion: Nothing advances by itself; the first panel is open and the others open instantly when chosen.
Running cost: The timer is a CSS animation on one thin bar, paused off screen, with a class change every few seconds.
- Set the time each panel stays open with `CYCLE_MS` in React or `--dur` on `.w5cyc-stage` in HTML.
- Change the slide feel with the `.9s` and easing on `.w5cyc-panel`; a slower curve suits a calmer brand.
- Recolour the countdown bar and accents by replacing `#e3b7a3`.
Expanding Bread Recipe Step Panels With Notes
A baking school's four-step method laid out as paper strips, each marked with a large step number, a one-word name and how long it takes. The open step lifts its paper cover to show a photo beside a short page of instructions and a tip, and Back and Next buttons walk through the method in order. Phones stack the strips with the photo above the text.
<section class="w5brd">
<div class="w5brd-wrap">
<p class="w5brd-eyebrow">Crumb School · Home baking notes</p>
<h2 class="w5brd-h2">Your first sourdough, in four steps</h2>
<div class="w5brd-stage">
<div class="w5brd-panel is-open" style="--i:0">
<div class="w5brd-body"><div class="w5brd-photo"><img src="https://images.pexels.com/photos/35369570/pexels-photo-35369570.jpeg?auto=compress&cs=tinysrgb&w=900" alt="Hands mixing a soft yellow dough in a metal bowl" loading="eager"></div><div class="w5brd-text" id="w5brd-text-0"><p class="w5brd-kick">Step 1 · 30 min</p><h3>Mix and rest</h3><p class="w5brd-p">Stir flour, water and a spoon of starter until no dry flour is left. Cover the bowl and leave it alone for half an hour.</p><p class="w5brd-tip">Use water at about hand warmth.</p></div></div>
<div class="w5brd-cover"></div>
<div class="w5brd-tab" aria-hidden="true"><span class="w5brd-num">01</span><span class="w5brd-word">Mix</span><span class="w5brd-time">30 min</span></div>
<button type="button" class="w5brd-hit" aria-expanded="true" aria-controls="w5brd-text-0"><span class="w5brd-sr">Step 1: Mix and rest</span></button>
</div>
<div class="w5brd-panel is-after" style="--i:1">
<div class="w5brd-body"><div class="w5brd-photo"><img src="https://images.pexels.com/photos/6287300/pexels-photo-6287300.jpeg?auto=compress&cs=tinysrgb&w=900" alt="Floured hands pressing a ball of dough on a wooden table" loading="lazy"></div><div class="w5brd-text" id="w5brd-text-1"><p class="w5brd-kick">Step 2 · 4 hours</p><h3>Fold and shape</h3><p class="w5brd-p">Every 45 minutes, lift one side of the dough and fold it over. After four rounds, shape it into a tight ball on a floured board.</p><p class="w5brd-tip">Wet hands stop the dough sticking.</p></div></div>
<div class="w5brd-cover"></div>
<div class="w5brd-tab" aria-hidden="true"><span class="w5brd-num">02</span><span class="w5brd-word">Fold</span><span class="w5brd-time">4 hours</span></div>
<button type="button" class="w5brd-hit" aria-expanded="false" aria-controls="w5brd-text-1"><span class="w5brd-sr">Step 2: Fold and shape</span></button>
</div>
<div class="w5brd-panel is-after" style="--i:2">
<div class="w5brd-body"><div class="w5brd-photo"><img src="https://images.pexels.com/photos/38699003/pexels-photo-38699003.jpeg?auto=compress&cs=tinysrgb&w=900" alt="Two raw scored loaves resting on parchment beside a wooden board" loading="lazy"></div><div class="w5brd-text" id="w5brd-text-2"><p class="w5brd-kick">Step 3 · Overnight</p><h3>Proof and score</h3><p class="w5brd-p">Rest the shaped loaf in the fridge overnight. In the morning, cut one confident slash or a leaf pattern across the top.</p><p class="w5brd-tip">A cold loaf is far easier to score.</p></div></div>
<div class="w5brd-cover"></div>
<div class="w5brd-tab" aria-hidden="true"><span class="w5brd-num">03</span><span class="w5brd-word">Proof</span><span class="w5brd-time">Overnight</span></div>
<button type="button" class="w5brd-hit" aria-expanded="false" aria-controls="w5brd-text-2"><span class="w5brd-sr">Step 3: Proof and score</span></button>
</div>
<div class="w5brd-panel is-after" style="--i:3">
<div class="w5brd-body"><div class="w5brd-photo"><img src="https://images.pexels.com/photos/38667647/pexels-photo-38667647.jpeg?auto=compress&cs=tinysrgb&w=900" alt="A baked sourdough loaf with a leaf pattern cut into its crust" loading="lazy"></div><div class="w5brd-text" id="w5brd-text-3"><p class="w5brd-kick">Step 4 · 45 min</p><h3>Bake it hot</h3><p class="w5brd-p">Bake in a lidded pot at the highest heat for 20 minutes, then take the lid off and finish until the crust is deep brown.</p><p class="w5brd-tip">Wait an hour before slicing.</p></div></div>
<div class="w5brd-cover"></div>
<div class="w5brd-tab" aria-hidden="true"><span class="w5brd-num">04</span><span class="w5brd-word">Bake</span><span class="w5brd-time">45 min</span></div>
<button type="button" class="w5brd-hit" aria-expanded="false" aria-controls="w5brd-text-3"><span class="w5brd-sr">Step 4: Bake it hot</span></button>
</div>
</div>
<div class="w5brd-foot">
<p class="w5brd-count" aria-live="polite">Step 1 of 4</p>
<div class="w5brd-btns"><button type="button" class="w5brd-back" disabled>Back</button><button type="button" class="w5brd-next">Next step</button></div>
</div>
</div>
</section>
<style>
/* Change these: --c is the closed strip width, --n the number of steps,
the stage height, and the .7s slide time on .w5brd-panel. */
.w5brd { background: #f3e9dc; padding: 56px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #3a2418; }
.w5brd-wrap { max-width: 1024px; margin: 0 auto; }
.w5brd-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: #a3401c; }
.w5brd-h2 { margin: 12px 0 32px; max-width: 36rem; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
.w5brd-kick { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #a3401c; }
.w5brd-text h3 { margin: 8px 0 0; font-size: 24px; line-height: 1.2; font-weight: 600; }
.w5brd-p { margin: 12px 0 0; font-size: 15px; line-height: 1.65; color: #5a3d2c; }
.w5brd-tip { margin: 16px 0 0; padding-left: 12px; border-left: 2px solid #a3401c; font-size: 14px; font-style: italic; color: #6b4a36; }
.w5brd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.w5brd-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; }
.w5brd-count { margin: 0; font-size: 14px; font-weight: 500; color: #5a3d2c; }
.w5brd-btns { display: flex; gap: 8px; }
.w5brd-btns button { height: 44px; padding: 0 20px; border-radius: 999px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.w5brd-back { border: 1px solid #c9ad90; background: transparent; color: #3a2418; }
.w5brd-next { border: 0; background: #a3401c; color: #fff; }
.w5brd-btns button:disabled { opacity: .4; cursor: default; }
.w5brd-btns button:focus-visible { outline: 2px solid #a3401c; outline-offset: 3px; }
.w5brd-stage{--c:96px;--n:4;--ow:calc(100% - (var(--n) - 1) * var(--c));position:relative;height:500px;overflow:hidden;border-radius:14px;background:#e9dccb;border:1px solid #dcc9b3}
.w5brd-panel{position:absolute;inset:0;z-index:var(--i);transform:translateX(calc(var(--i) * var(--c)));transition:transform .7s cubic-bezier(.22,1,.36,1);background:#f8f1e7;border-left:1px solid #dcc9b3}
.w5brd-panel:first-child{border-left:0}
.w5brd-panel.is-after{transform:translateX(calc(100% - (var(--n) - var(--i)) * var(--c)))}
.w5brd-body{position:absolute;top:0;left:0;bottom:0;width:var(--ow);display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,1fr)}
.w5brd-photo{position:relative;overflow:hidden;background:#d9c4ab}
.w5brd-photo img{display:block;width:100%;height:100%;object-fit:cover;transform:scale(1.12);transition:transform 1s cubic-bezier(.22,1,.36,1)}
.is-open .w5brd-photo img{transform:none}
.w5brd-text{padding:36px 32px;box-sizing:border-box;color:#3a2418;opacity:0;transform:translateX(18px);transition:opacity .25s,transform .25s}
.is-open .w5brd-text{opacity:1;transform:none;transition:opacity .45s .35s,transform .6s .35s cubic-bezier(.22,1,.36,1)}
.w5brd-cover{position:absolute;inset:0;background:#f8f1e7;transition:opacity .45s .1s;pointer-events:none}
.is-open .w5brd-cover{opacity:0}
.w5brd-tab{position:absolute;top:0;left:0;bottom:0;width:var(--c);display:flex;flex-direction:column;align-items:center;justify-content:space-between;padding:26px 0;box-sizing:border-box;color:#a3401c;pointer-events:none;transition:opacity .3s}
.is-open .w5brd-tab{opacity:0}
.w5brd-num{font-size:34px;font-weight:700;line-height:1;font-variant-numeric:tabular-nums}
.w5brd-word{writing-mode:vertical-rl;transform:rotate(180deg);font-size:15px;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:#3a2418}
.w5brd-time{font-size:12px;font-weight:600;color:#6b4a36}
.w5brd-hit{position:absolute;top:0;left:0;bottom:0;width:var(--c);padding:0;border:0;background:transparent;cursor:pointer}
.is-open .w5brd-hit{width:calc(var(--ow) * 0.52);cursor:default}
.w5brd-hit:focus-visible{outline:3px solid #a3401c;outline-offset:-6px;border-radius:10px}
@media (max-width:640px){
.w5brd-stage{--c:60px;height:640px}
.w5brd-panel{transform:translateY(calc(var(--i) * var(--c)));border-left:0;border-top:1px solid #dcc9b3}
.w5brd-panel:first-child{border-top:0}
.w5brd-panel.is-after{transform:translateY(calc(100% - (var(--n) - var(--i)) * var(--c)))}
.w5brd-body{right:0;bottom:auto;width:auto;height:var(--ow);grid-template-columns:none;grid-template-rows:170px minmax(0,1fr)}
.w5brd-text{padding:18px 20px;transform:translateY(12px)}
.w5brd-tab{right:0;bottom:auto;width:auto;height:var(--c);flex-direction:row;justify-content:flex-start;gap:16px;padding:0 20px}
.w5brd-num{font-size:24px}
.w5brd-word{writing-mode:horizontal-tb;transform:none}
.w5brd-time{margin-left:auto}
.w5brd-hit{right:0;bottom:auto;width:auto;height:var(--c)}
.is-open .w5brd-hit{width:auto;height:170px}
}
@media (prefers-reduced-motion:reduce){.w5brd-panel,.w5brd-photo img,.w5brd-text,.is-open .w5brd-text,.w5brd-cover,.w5brd-tab{transition:none}}
</style>
<script>
(function () {
/* Change this: how long (ms) the mouse rests on a step before it opens. */
var HOVER_DELAY = 80;
var root = document.querySelector(".w5brd");
if (!root) return;
var panels = [].slice.call(root.querySelectorAll(".w5brd-panel")), timer = 0, cur = 0;
var back = root.querySelector(".w5brd-back"), next = root.querySelector(".w5brd-next"), count = root.querySelector(".w5brd-count");
function open(k) {
cur = k;
panels.forEach(function (p, i) {
p.classList.toggle("is-open", i === k);
p.classList.toggle("is-after", i > k);
p.querySelector(".w5brd-hit").setAttribute("aria-expanded", i === k ? "true" : "false");
});
back.disabled = k === 0;
next.disabled = k === panels.length - 1;
count.textContent = "Step " + (k + 1) + " of " + panels.length;
}
panels.forEach(function (p, i) {
var b = p.querySelector(".w5brd-hit");
b.addEventListener("pointerenter", function (e) {
if (e.pointerType !== "mouse") return;
clearTimeout(timer);
timer = setTimeout(function () { open(i); }, HOVER_DELAY);
});
b.addEventListener("pointerleave", function () { clearTimeout(timer); });
b.addEventListener("focus", function () { open(i); });
b.addEventListener("click", function () { open(i); });
});
back.addEventListener("click", function () { if (cur > 0) open(cur - 1); });
next.addEventListener("click", function () { if (cur < panels.length - 1) open(cur + 1); });
})();
</script>
With reduced motion: Steps change instantly with the paper cover removed at once and the notes already in place.
Running cost: Each step change animates transforms and opacity on four panels and then the page is idle.
- Rewrite the method in `STEPS`; each entry has a one-word strip label, a title, a time, the instructions and a tip.
- Change the photo to text balance with the `grid-template-columns` on `.w5brd-body`.
- Recolour the numbers and buttons by replacing `#a3401c`, and the paper with `#f8f1e7`.
Expanding Class Panels as Keyboard Tabs
A pottery studio's class list built as photo panels that are also a proper tab set. Each closed panel is a tab labelled with the class name; the open one shows its photo, price, length and weekly time. Arrow keys, Home and End move between classes the way screen reader users expect from tabs, and hover and tap open them as well. Phones get stacked rows.
<section class="w5tab">
<div class="w5tab-wrap">
<div class="w5tab-head">
<div><p class="w5tab-eyebrow">Slow Clay Studio</p><h2 class="w5tab-h2">Winter classes</h2></div>
<p class="w5tab-lede">Hover, tap or use the arrow keys to move between classes. Clay, glazes and firing are included.</p>
</div>
<div class="w5tab-stage">
<div class="w5tab-list" role="tablist" aria-label="Pottery classes" aria-orientation="horizontal">
<div class="w5tab-slot" style="--i:0"><button type="button" role="tab" class="w5tab-tab" id="w5tab-tab-0" aria-selected="true" aria-controls="w5tab-pane-0" tabindex="0" data-name="wheel throwing"><span class="w5tab-label">Wheel throwing</span></button></div>
<div class="w5tab-slot is-after" style="--i:1"><button type="button" role="tab" class="w5tab-tab" id="w5tab-tab-1" aria-selected="false" aria-controls="w5tab-pane-1" tabindex="-1" data-name="hand building"><span class="w5tab-label">Hand building</span></button></div>
<div class="w5tab-slot is-after" style="--i:2"><button type="button" role="tab" class="w5tab-tab" id="w5tab-tab-2" aria-selected="false" aria-controls="w5tab-pane-2" tabindex="-1" data-name="glaze lab"><span class="w5tab-label">Glaze lab</span></button></div>
<div class="w5tab-slot is-after" style="--i:3"><button type="button" role="tab" class="w5tab-tab" id="w5tab-tab-3" aria-selected="false" aria-controls="w5tab-pane-3" tabindex="-1" data-name="kiln and firing"><span class="w5tab-label">Kiln and firing</span></button></div>
</div>
<div class="w5tab-panel is-open" style="--i:0">
<div class="w5tab-media"><img src="https://images.pexels.com/photos/36370411/pexels-photo-36370411.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Two hands shaping a clay pot on a spinning potter's wheel" loading="eager"><div class="w5tab-shade"></div><div class="w5tab-tint"></div></div>
<div class="w5tab-pane" role="tabpanel" id="w5tab-pane-0" aria-labelledby="w5tab-tab-0" tabindex="0"><p class="w5tab-kick">6 weeks · $320</p><h3>Wheel throwing</h3><p class="w5tab-line">Centre, open and pull your first cylinders, then trim and keep the best four.</p><p class="w5tab-when">Thursdays, 6:30 to 9 pm</p></div>
</div>
<div class="w5tab-panel is-after" style="--i:1">
<div class="w5tab-media"><img src="https://images.pexels.com/photos/7302675/pexels-photo-7302675.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Clay coils and small rings laid out with tools on a pale table" loading="lazy"><div class="w5tab-shade"></div><div class="w5tab-tint"></div></div>
<div class="w5tab-pane" role="tabpanel" id="w5tab-pane-1" aria-labelledby="w5tab-tab-1" tabindex="0" hidden><p class="w5tab-kick">4 weeks · $240</p><h3>Hand building</h3><p class="w5tab-line">Pinch, coil and slab your way to a set of cups without touching a wheel.</p><p class="w5tab-when">Saturdays, 10 am to 1 pm</p></div>
</div>
<div class="w5tab-panel is-after" style="--i:2">
<div class="w5tab-media"><img src="https://images.pexels.com/photos/6800483/pexels-photo-6800483.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A potter painting a bowl beside trays of coloured glazes" loading="lazy"><div class="w5tab-shade"></div><div class="w5tab-tint"></div></div>
<div class="w5tab-pane" role="tabpanel" id="w5tab-pane-2" aria-labelledby="w5tab-tab-2" tabindex="0" hidden><p class="w5tab-kick">3 weeks · $180</p><h3>Glaze lab</h3><p class="w5tab-line">Mix test tiles, layer colours and learn why a glaze runs or crawls.</p><p class="w5tab-when">Tuesdays, 7 to 9 pm</p></div>
</div>
<div class="w5tab-panel is-after" style="--i:3">
<div class="w5tab-media"><img src="https://images.pexels.com/photos/9736510/pexels-photo-9736510.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Stacks of unglazed earthenware plates inside an open kiln" loading="lazy"><div class="w5tab-shade"></div><div class="w5tab-tint"></div></div>
<div class="w5tab-pane" role="tabpanel" id="w5tab-pane-3" aria-labelledby="w5tab-tab-3" tabindex="0" hidden><p class="w5tab-kick">1 day · $150</p><h3>Kiln and firing</h3><p class="w5tab-line">Load, fire and unload with our kiln tech, and see how heat changes clay.</p><p class="w5tab-when">One Sunday, 10 am to 4 pm</p></div>
</div>
</div>
<div class="w5tab-foot">
<p>Eight places per class. Aprons and tools are ready on your bench.</p>
<a class="w5tab-book" href="#">Book <span class="w5tab-cur">wheel throwing</span></a>
</div>
</div>
</section>
<style>
/* Change these: --c is the closed tab width, --n the number of classes,
the stage height, and the .7s slide time on .w5tab-panel. */
.w5tab { background: #0e1a2b; padding: 56px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #f4ead8; }
.w5tab-wrap { max-width: 1152px; margin: 0 auto; }
.w5tab-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 32px; }
.w5tab-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: #e9c58f; }
.w5tab-h2 { margin: 12px 0 0; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
.w5tab-lede { margin: 0; max-width: 24rem; font-size: 14px; line-height: 1.6; color: #c3cbd6; }
.w5tab-kick { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #e9c58f; }
.w5tab-pane h3 { margin: 8px 0 0; font-size: 30px; line-height: 1.15; font-weight: 600; }
.w5tab-line { margin: 12px 0 0; max-width: 20rem; font-size: 16px; line-height: 1.6; color: #dfe4ea; }
.w5tab-when { margin: 16px 0 0; font-size: 14px; font-weight: 500; }
.w5tab-pane[hidden] { display: none; }
.w5tab-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; }
.w5tab-foot p { margin: 0; font-size: 14px; color: #c3cbd6; }
.w5tab-book { display: inline-flex; align-items: center; gap: 4px; height: 44px; padding: 0 24px; border-radius: 999px; background: #e9c58f; color: #0e1a2b; font-size: 14px; font-weight: 600; text-decoration: none; }
.w5tab-book:hover { background: #f2d6ab; }
.w5tab-book:focus-visible { outline: 2px solid #e9c58f; outline-offset: 3px; }
.w5tab-stage{--c:80px;--n:4;--ow:calc(100% - (var(--n) - 1) * var(--c));position:relative;height:500px;overflow:hidden;border-radius:20px;background:#0a1420}
.w5tab-slot,.w5tab-panel{position:absolute;inset:0;transform:translateX(calc(var(--i) * var(--c)));transition:transform .7s cubic-bezier(.22,1,.36,1)}
.w5tab-panel{z-index:var(--i);box-shadow:-10px 0 26px rgba(4,10,18,.45)}
.w5tab-slot{pointer-events:none}
.w5tab-slot.is-after,.w5tab-panel.is-after{transform:translateX(calc(100% - (var(--n) - var(--i)) * var(--c)))}
.w5tab-media{position:absolute;top:0;left:0;bottom:0;width:var(--ow);overflow:hidden;background:#15253a}
.w5tab-media img{display:block;width:100%;height:100%;object-fit:cover;transform:translateX(calc(var(--c) / 2 - 50%)) scale(1.08);transition:transform .9s cubic-bezier(.22,1,.36,1)}
.is-open .w5tab-media img{transform:none}
.w5tab-tint{position:absolute;inset:0;background:rgba(14,26,43,.42);transition:opacity .5s}
.is-open .w5tab-tint{opacity:0}
.w5tab-shade{position:absolute;inset:0;background:linear-gradient(to right,rgba(10,20,32,.9),rgba(10,20,32,.55) 45%,rgba(10,20,32,0) 75%)}
.w5tab-list{position:absolute;inset:0;z-index:20;pointer-events:none}
.w5tab-tab{position:absolute;top:0;left:0;bottom:0;width:var(--c);display:flex;align-items:center;justify-content:center;padding:0;border:0;background:transparent;color:#f4ead8;font:inherit;cursor:pointer;pointer-events:auto}
.w5tab-tab[aria-selected="true"]{width:var(--ow);cursor:default}
.w5tab-tab:focus-visible{outline:3px solid #e9c58f;outline-offset:-7px;border-radius:14px}
.w5tab-label{writing-mode:vertical-rl;transform:rotate(180deg);font-size:15px;font-weight:600;letter-spacing:.06em;white-space:nowrap;transition:opacity .3s}
.w5tab-tab[aria-selected="true"] .w5tab-label{opacity:0}
.w5tab-pane{position:absolute;top:0;left:0;bottom:0;width:var(--ow);box-sizing:border-box;display:flex;flex-direction:column;justify-content:center;padding:40px;color:#f4ead8;z-index:30;pointer-events:none;animation:w5tab-in .6s .3s both cubic-bezier(.22,1,.36,1)}
.w5tab-pane:focus-visible{outline:3px solid #e9c58f;outline-offset:-7px;border-radius:14px}
@keyframes w5tab-in{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
@media (max-width:640px){
.w5tab-stage{--c:56px;height:600px}
.w5tab-slot,.w5tab-panel{transform:translateY(calc(var(--i) * var(--c)))}
.w5tab-panel{box-shadow:0 -10px 26px rgba(4,10,18,.45)}
.w5tab-slot.is-after,.w5tab-panel.is-after{transform:translateY(calc(100% - (var(--n) - var(--i)) * var(--c)))}
.w5tab-media{right:0;bottom:auto;width:auto;height:var(--ow)}
.w5tab-media img{transform:translateY(calc(var(--c) / 2 - 50%)) scale(1.08)}
.w5tab-shade{background:linear-gradient(to top,rgba(10,20,32,.92),rgba(10,20,32,.5) 55%,rgba(10,20,32,0) 80%)}
.w5tab-tab{right:0;bottom:auto;width:auto;height:var(--c);justify-content:flex-start;padding:0 20px}
.w5tab-tab[aria-selected="true"]{width:auto;height:var(--ow)}
.w5tab-label{writing-mode:horizontal-tb;transform:none}
.w5tab-pane{right:0;bottom:auto;width:auto;height:var(--ow);justify-content:flex-end;padding:22px}
}
@media (prefers-reduced-motion:reduce){.w5tab-slot,.w5tab-panel,.w5tab-media img,.w5tab-tint,.w5tab-label{transition:none}.w5tab-pane{animation:none}}
</style>
<script>
(function () {
/* Change this: how long (ms) the mouse rests on a tab before it opens. */
var HOVER_DELAY = 90;
var root = document.querySelector(".w5tab");
if (!root) return;
var tabs = [].slice.call(root.querySelectorAll(".w5tab-tab"));
var slots = root.querySelectorAll(".w5tab-slot"), panels = root.querySelectorAll(".w5tab-panel");
var cur = 0, timer = 0, n = tabs.length, label = root.querySelector(".w5tab-cur");
function open(k) {
if (k === cur) return;
cur = k;
tabs.forEach(function (t, i) {
var on = i === k;
t.setAttribute("aria-selected", on ? "true" : "false");
t.tabIndex = on ? 0 : -1;
slots[i].classList.toggle("is-after", i > k);
panels[i].classList.toggle("is-after", i > k);
panels[i].classList.toggle("is-open", on);
panels[i].querySelector(".w5tab-pane").hidden = !on;
});
label.textContent = tabs[k].getAttribute("data-name");
}
tabs.forEach(function (t, i) {
t.addEventListener("pointerenter", function (e) {
if (e.pointerType !== "mouse") return;
clearTimeout(timer);
timer = setTimeout(function () { open(i); }, HOVER_DELAY);
});
t.addEventListener("pointerleave", function () { clearTimeout(timer); });
t.addEventListener("focus", function () { open(i); });
t.addEventListener("click", function () { open(i); });
});
root.querySelector(".w5tab-list").addEventListener("keydown", function (e) {
var map = { ArrowRight: cur + 1, ArrowDown: cur + 1, ArrowLeft: cur - 1, ArrowUp: cur - 1, Home: 0, End: n - 1 };
if (!(e.key in map)) return;
e.preventDefault();
var k = (map[e.key] + n) % n;
open(k);
tabs[k].focus();
});
})();
</script>
With reduced motion: Tabs switch instantly and the class details appear without the slide or the rising fade.
Running cost: Selecting a tab moves a handful of layers with transforms and fades one panel in; it is idle otherwise.
- Edit the classes in `CLASSES`; the booking button below the stage picks up the open class name.
- Widen or narrow the closed tabs with `--c` on `.w5tab-stage`, keeping `--n` equal to the number of classes.
- Change how dark the closed panels look with the alpha in `.w5tab-tint`.
Expanding Product Colourway Panels With Swatches
A product block where every colourway gets its own panel. Closed panels read as flat glaze swatches with the colour name set sideways; opening one fades the swatch away to show the photo, while the details column beside it updates the piece name, a short glaze note and the buy button. Round swatch buttons offer a second way in, and on phones the panels stack.
<section class="w5clr">
<div class="w5clr-wrap">
<div class="w5clr-stage">
<div class="w5clr-panel is-open" style="--i:0;--hex:#d8c2ad;--ink:#3b2f25" data-name="Oat bud vase" data-note="A warm, satin cream that looks like unbleached linen in daylight.">
<div class="w5clr-media"><img src="https://images.pexels.com/photos/7663201/pexels-photo-7663201.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Small cream bud vase standing on a blush-coloured backdrop" loading="eager"><div class="w5clr-swatch"></div></div>
<span class="w5clr-tag" aria-hidden="true">Oat bud vase</span>
<div class="w5clr-tab" aria-hidden="true"><span class="w5clr-name">Oat bud vase</span></div>
<button type="button" class="w5clr-hit" aria-expanded="true" aria-label="Oat bud vase"></button>
</div>
<div class="w5clr-panel is-after" style="--i:1;--hex:#7c9a88;--ink:#142019" data-name="Celadon speckled vase" data-note="Sage green with dark iron flecks that pool where the glaze runs thick.">
<div class="w5clr-media"><img src="https://images.pexels.com/photos/11889250/pexels-photo-11889250.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Speckled green glazed vase on a plain white backdrop" loading="lazy"><div class="w5clr-swatch"></div></div>
<span class="w5clr-tag" aria-hidden="true">Celadon speckled vase</span>
<div class="w5clr-tab" aria-hidden="true"><span class="w5clr-name">Celadon speckled vase</span></div>
<button type="button" class="w5clr-hit" aria-expanded="false" aria-label="Celadon speckled vase"></button>
</div>
<div class="w5clr-panel is-after" style="--i:2;--hex:#3d7fb0;--ink:#ffffff" data-name="Lake bottle vase" data-note="A glossy mid blue, brightest on the shoulder and deeper near the foot.">
<div class="w5clr-media"><img src="https://images.pexels.com/photos/8725870/pexels-photo-8725870.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Slim blue vase holding a single white flower in a bright room" loading="lazy"><div class="w5clr-swatch"></div></div>
<span class="w5clr-tag" aria-hidden="true">Lake bottle vase</span>
<div class="w5clr-tab" aria-hidden="true"><span class="w5clr-name">Lake bottle vase</span></div>
<button type="button" class="w5clr-hit" aria-expanded="false" aria-label="Lake bottle vase"></button>
</div>
<div class="w5clr-panel is-after" style="--i:3;--hex:#2a2a2d;--ink:#ffffff" data-name="Coal stoneware jug" data-note="Matte black stoneware with a faint sheen where your hand will hold it.">
<div class="w5clr-media"><img src="https://images.pexels.com/photos/28055261/pexels-photo-28055261.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Black stoneware jug resting on a book on a white shelf" loading="lazy"><div class="w5clr-swatch"></div></div>
<span class="w5clr-tag" aria-hidden="true">Coal stoneware jug</span>
<div class="w5clr-tab" aria-hidden="true"><span class="w5clr-name">Coal stoneware jug</span></div>
<button type="button" class="w5clr-hit" aria-expanded="false" aria-label="Coal stoneware jug"></button>
</div>
<div class="w5clr-panel is-after" style="--i:4;--hex:#e7e3da;--ink:#2d2b27" data-name="Chalk ring vase" data-note="Dry white, soft to the touch, and the quietest of the five on a shelf.">
<div class="w5clr-media"><img src="https://images.pexels.com/photos/33105316/pexels-photo-33105316.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="White ring-shaped vase on a shelf in deep shadow" loading="lazy"><div class="w5clr-swatch"></div></div>
<span class="w5clr-tag" aria-hidden="true">Chalk ring vase</span>
<div class="w5clr-tab" aria-hidden="true"><span class="w5clr-name">Chalk ring vase</span></div>
<button type="button" class="w5clr-hit" aria-expanded="false" aria-label="Chalk ring vase"></button>
</div>
</div>
<div class="w5clr-info">
<p class="w5clr-eyebrow">Kiln & Field Pottery</p>
<h2 class="w5clr-h2">Five glazes from the studio</h2>
<p class="w5clr-price">$48</p>
<div class="w5clr-now" aria-live="polite">
<p class="w5clr-now-name">Showing: <span class="w5clr-cur">Oat bud vase</span></p>
<p class="w5clr-note">A warm, satin cream that looks like unbleached linen in daylight.</p>
</div>
<div class="w5clr-dots" role="group" aria-label="Choose a glaze">
<button type="button" class="w5clr-dot" aria-pressed="true" aria-label="Oat bud vase" style="background:#d8c2ad"></button>
<button type="button" class="w5clr-dot" aria-pressed="false" aria-label="Celadon speckled vase" style="background:#7c9a88"></button>
<button type="button" class="w5clr-dot" aria-pressed="false" aria-label="Lake bottle vase" style="background:#3d7fb0"></button>
<button type="button" class="w5clr-dot" aria-pressed="false" aria-label="Coal stoneware jug" style="background:#2a2a2d"></button>
<button type="button" class="w5clr-dot" aria-pressed="false" aria-label="Chalk ring vase" style="background:#e7e3da"></button>
</div>
<button type="button" class="w5clr-buy">Add <span class="w5clr-cur">Oat bud vase</span> to bag</button>
<p class="w5clr-small">Each piece is thrown and glazed by hand, so no two are quite alike.</p>
</div>
</div>
</section>
<style>
/* Change these: --c is the closed swatch width, --n the number of colourways,
the stage height, and each panel's --hex (swatch) and --ink (label) colours. */
.w5clr { background: #fff; padding: 56px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #0f172a; }
.w5clr-wrap { max-width: 1152px; margin: 0 auto; display: grid; gap: 40px; }
@media (min-width: 1024px) { .w5clr-wrap { grid-template-columns: 7fr 5fr; align-items: center; } }
.w5clr-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: #475569; }
.w5clr-h2 { margin: 12px 0 0; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
.w5clr-price { margin: 12px 0 0; font-size: 24px; font-weight: 500; }
.w5clr-now { margin-top: 24px; padding-top: 24px; border-top: 1px solid #e2e8f0; }
.w5clr-now-name { margin: 0; font-size: 14px; font-weight: 600; }
.w5clr-note { margin: 4px 0 0; max-width: 24rem; font-size: 16px; line-height: 1.6; color: #475569; }
.w5clr-dots { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.w5clr-dot { width: 44px; height: 44px; border-radius: 999px; border: 1px solid #cbd5e1; cursor: pointer; }
.w5clr-dot[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0f172a; }
.w5clr-dot:focus-visible { outline: 2px solid #0f172a; outline-offset: 4px; }
.w5clr-buy { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 48px; margin-top: 32px; padding: 0 24px; border: 0; border-radius: 8px; background: #0f172a; color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.w5clr-buy:hover { background: #334155; }
.w5clr-buy:focus-visible { outline: 2px solid #0f172a; outline-offset: 3px; }
.w5clr-small { margin: 16px 0 0; font-size: 14px; color: #475569; }
.w5clr-stage { --c: 64px; --n: 5; --ow: calc(100% - (var(--n) - 1) * var(--c)); position: relative; height: 540px; overflow: hidden; border-radius: 16px; background: #e2e8f0; }
.w5clr-panel { position: absolute; inset: 0; z-index: var(--i); transform: translateX(calc(var(--i) * var(--c))); transition: transform .7s cubic-bezier(.22,1,.36,1); box-shadow: -6px 0 18px rgba(15,23,42,.14); }
.w5clr-panel.is-after { transform: translateX(calc(100% - (var(--n) - var(--i)) * var(--c))); }
.w5clr-media { position: absolute; top: 0; left: 0; bottom: 0; width: var(--ow); overflow: hidden; }
.w5clr-media img { display: block; width: 100%; height: 100%; object-fit: cover; transform: translateX(calc(var(--c) / 2 - 50%)) scale(1.05); transition: transform .8s cubic-bezier(.22,1,.36,1); }
.is-open .w5clr-media img { transform: none; }
.w5clr-swatch { position: absolute; inset: 0; background: var(--hex); transition: opacity .55s .1s; }
.is-open .w5clr-swatch { opacity: 0; transition: opacity .6s .15s; }
.w5clr-tab { position: absolute; top: 0; left: 0; bottom: 0; width: var(--c); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 22px 0; box-sizing: border-box; color: var(--ink); pointer-events: none; transition: opacity .3s; }
.is-open .w5clr-tab { opacity: 0; }
.w5clr-name { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 13px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; white-space: nowrap; }
.w5clr-tag { position: absolute; top: 18px; left: 18px; padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,.92); color: #0f172a; font-size: 12px; font-weight: 600; letter-spacing: .04em; opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; pointer-events: none; }
.is-open .w5clr-tag { opacity: 1; transform: none; transition: opacity .4s .4s, transform .5s .4s; }
.w5clr-hit { position: absolute; top: 0; left: 0; bottom: 0; width: var(--c); padding: 0; border: 0; background: transparent; cursor: pointer; }
.is-open .w5clr-hit { width: var(--ow); cursor: default; }
.w5clr-hit:focus-visible { outline: 3px solid #0f172a; outline-offset: -6px; border-radius: 12px; box-shadow: inset 0 0 0 6px #fff; }
@media (max-width: 640px) {
.w5clr-stage { --c: 52px; height: 520px; }
.w5clr-panel { transform: translateY(calc(var(--i) * var(--c))); box-shadow: 0 -6px 18px rgba(15,23,42,.14); }
.w5clr-panel.is-after { transform: translateY(calc(100% - (var(--n) - var(--i)) * var(--c))); }
.w5clr-media { right: 0; bottom: auto; width: auto; height: var(--ow); }
.w5clr-media img { transform: translateY(calc(var(--c) / 2 - 50%)) scale(1.05); }
.w5clr-tab { right: 0; bottom: auto; width: auto; height: var(--c); flex-direction: row; justify-content: flex-start; padding: 0 18px; }
.w5clr-name { writing-mode: horizontal-tb; transform: none; }
.w5clr-hit { right: 0; bottom: auto; width: auto; height: var(--c); }
.is-open .w5clr-hit { width: auto; height: var(--ow); }
.w5clr-buy { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
.w5clr-panel, .w5clr-media img, .w5clr-swatch, .is-open .w5clr-swatch, .w5clr-tab, .w5clr-tag, .is-open .w5clr-tag { transition: none; }
}
</style>
<script>
(function () {
/* Change this: how long (ms) the mouse rests on a swatch before it opens. */
var HOVER_DELAY = 70;
var root = document.querySelector(".w5clr");
if (!root) return;
var panels = [].slice.call(root.querySelectorAll(".w5clr-panel"));
var dots = [].slice.call(root.querySelectorAll(".w5clr-dot"));
var curs = root.querySelectorAll(".w5clr-cur"), note = root.querySelector(".w5clr-note"), timer = 0;
function open(k) {
panels.forEach(function (p, i) {
p.classList.toggle("is-open", i === k);
p.classList.toggle("is-after", i > k);
p.querySelector(".w5clr-hit").setAttribute("aria-expanded", i === k ? "true" : "false");
dots[i].setAttribute("aria-pressed", i === k ? "true" : "false");
});
for (var j = 0; j < curs.length; j++) curs[j].textContent = panels[k].getAttribute("data-name");
note.textContent = panels[k].getAttribute("data-note");
}
panels.forEach(function (p, i) {
var b = p.querySelector(".w5clr-hit");
b.addEventListener("pointerenter", function (e) {
if (e.pointerType !== "mouse") return;
clearTimeout(timer);
timer = setTimeout(function () { open(i); }, HOVER_DELAY);
});
b.addEventListener("pointerleave", function () { clearTimeout(timer); });
b.addEventListener("focus", function () { open(i); });
b.addEventListener("click", function () { open(i); });
dots[i].addEventListener("click", function () { open(i); });
});
})();
</script>
With reduced motion: The chosen colourway swaps in at once and the swatch layer disappears without a fade.
Running cost: A few transforms and one opacity fade per change, with no work while nothing is being chosen.
- Set each colourway's swatch with `--hex` and its label colour with `--ink` on the panel, choosing an ink that reads clearly on that swatch.
- Edit names and notes in `GLAZES` (React) or the `data-name` and `data-note` attributes (HTML).
- Narrow the swatches with `--c` on `.w5clr-stage` if you add more than five finishes.
Expanding Team Portrait Panels With Bios
An about-page block for a small studio: a short pitch on the left and four portrait strips on the right. Closed strips sit in muted grey with initials and a name, and the open one turns to full colour with a white bio card that settles in after the slide. Phones get the same strips stacked as rows.
<section class="w5tem">
<div class="w5tem-wrap">
<div class="w5tem-intro">
<p class="w5tem-eyebrow">Hollis & Rowe Architects</p>
<h2 class="w5tem-h2">The four people who will draw your building</h2>
<p class="w5tem-lede">A small practice on purpose. Whoever meets you on the first visit stays on the job until the keys are handed over.</p>
<a class="w5tem-btn" href="#">Book a studio visit</a>
</div>
<div class="w5tem-stage">
<div class="w5tem-panel is-open" style="--i:0">
<div class="w5tem-media"><img src="https://images.pexels.com/photos/8727416/pexels-photo-8727416.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Smiling woman with short white hair in a white T-shirt against a blue-grey wall" loading="eager" style="object-position:50% 30%"><div class="w5tem-mono"></div><div class="w5tem-veil"></div></div>
<div class="w5tem-tab" aria-hidden="true"><span class="w5tem-ini">MH</span><span class="w5tem-name">Margit Hollis</span></div>
<button type="button" class="w5tem-hit" aria-expanded="true" aria-controls="w5tem-card-0"><span class="w5tem-sr">Margit Hollis, Founding partner</span></button>
<div class="w5tem-card" id="w5tem-card-0"><h3>Margit Hollis</h3><p class="w5tem-role">Founding partner</p><p class="w5tem-bio">Thirty years of schools and libraries. Still sketches every first plan by hand.</p><a href="#">Write to Margit</a></div>
</div>
<div class="w5tem-panel is-after" style="--i:1">
<div class="w5tem-media"><img src="https://images.pexels.com/photos/31052395/pexels-photo-31052395.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Young man with curly black hair and round glasses in a black shirt" loading="lazy" style="object-position:50% 25%"><div class="w5tem-mono"></div><div class="w5tem-veil"></div></div>
<div class="w5tem-tab" aria-hidden="true"><span class="w5tem-ini">TL</span><span class="w5tem-name">Theo Lin</span></div>
<button type="button" class="w5tem-hit" aria-expanded="false" aria-controls="w5tem-card-1"><span class="w5tem-sr">Theo Lin, Project architect</span></button>
<div class="w5tem-card" id="w5tem-card-1"><h3>Theo Lin</h3><p class="w5tem-role">Project architect</p><p class="w5tem-bio">Runs our timber housing work and the studio's slightly obsessive model shop.</p><a href="#" tabindex="-1">Write to Theo</a></div>
</div>
<div class="w5tem-panel is-after" style="--i:2">
<div class="w5tem-media"><img src="https://images.pexels.com/photos/10019539/pexels-photo-10019539.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Bearded man in a patterned shirt against a plain white background" loading="lazy" style="object-position:50% 95%"><div class="w5tem-mono"></div><div class="w5tem-veil"></div></div>
<div class="w5tem-tab" aria-hidden="true"><span class="w5tem-ini">AM</span><span class="w5tem-name">Arjun Mehta</span></div>
<button type="button" class="w5tem-hit" aria-expanded="false" aria-controls="w5tem-card-2"><span class="w5tem-sr">Arjun Mehta, Site lead</span></button>
<div class="w5tem-card" id="w5tem-card-2"><h3>Arjun Mehta</h3><p class="w5tem-role">Site lead</p><p class="w5tem-bio">Turns drawings into buildings and keeps every contractor on first-name terms.</p><a href="#" tabindex="-1">Write to Arjun</a></div>
</div>
<div class="w5tem-panel is-after" style="--i:3">
<div class="w5tem-media"><img src="https://images.pexels.com/photos/4698776/pexels-photo-4698776.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Woman with long curly hair leaning by a window and looking at the camera" loading="lazy" style="object-position:50% 35%"><div class="w5tem-mono"></div><div class="w5tem-veil"></div></div>
<div class="w5tem-tab" aria-hidden="true"><span class="w5tem-ini">CR</span><span class="w5tem-name">Clara Rowe</span></div>
<button type="button" class="w5tem-hit" aria-expanded="false" aria-controls="w5tem-card-3"><span class="w5tem-sr">Clara Rowe, Interiors and light</span></button>
<div class="w5tem-card" id="w5tem-card-3"><h3>Clara Rowe</h3><p class="w5tem-role">Interiors and light</p><p class="w5tem-bio">Plans how each room feels at seven in the morning and at seven at night.</p><a href="#" tabindex="-1">Write to Clara</a></div>
</div>
</div>
</div>
</section>
<style>
/* Change these: --c is the closed strip width, --n the number of people,
the stage height, and the .7s slide time on .w5tem-panel. */
.w5tem { background: #f3f3f1; padding: 56px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #1d1f22; }
.w5tem-wrap { max-width: 1152px; margin: 0 auto; display: grid; gap: 40px; }
@media (min-width: 1024px) { .w5tem-wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: center; } }
.w5tem-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: #475569; }
.w5tem-h2 { margin: 12px 0 0; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
.w5tem-lede { margin: 16px 0 0; font-size: 16px; line-height: 1.6; color: #475569; }
.w5tem-btn { display: inline-flex; align-items: center; height: 44px; margin-top: 24px; padding: 0 24px; border-radius: 999px; background: #1d1f22; color: #fff; font-size: 14px; font-weight: 600; text-decoration: none; }
.w5tem-btn:hover { background: #000; }
.w5tem-btn:focus-visible { outline: 2px solid #1d1f22; outline-offset: 3px; }
.w5tem-stage { --c: 84px; --n: 4; --ow: calc(100% - (var(--n) - 1) * var(--c)); position: relative; height: 560px; overflow: hidden; border-radius: 6px; background: #1d1f22; }
.w5tem-panel { position: absolute; inset: 0; z-index: var(--i); transform: translateX(calc(var(--i) * var(--c))); transition: transform .7s cubic-bezier(.2,.9,.25,1); border-left: 1px solid rgba(255,255,255,.35); }
.w5tem-panel:first-child { border-left: 0; }
.w5tem-panel.is-after { transform: translateX(calc(100% - (var(--n) - var(--i)) * var(--c))); }
.w5tem-media { position: absolute; top: 0; left: 0; bottom: 0; width: var(--ow); overflow: hidden; background: #2a2d31; }
.w5tem-media img { display: block; width: 100%; height: 100%; object-fit: cover; transform: translateX(calc(var(--c) / 2 - 50%)) scale(1.06); transition: transform .8s cubic-bezier(.2,.9,.25,1); }
.is-open .w5tem-media img { transform: none; }
.w5tem-mono { position: absolute; inset: 0; background: #8a8d91; mix-blend-mode: saturation; transition: opacity .6s; }
.w5tem-veil { position: absolute; inset: 0; background: rgba(20,22,25,.35); transition: opacity .6s; }
.is-open .w5tem-mono, .is-open .w5tem-veil { opacity: 0; }
.w5tem-tab { position: absolute; top: 0; left: 0; bottom: 0; width: var(--c); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 22px 0; box-sizing: border-box; color: #fff; pointer-events: none; transition: opacity .3s; }
.is-open .w5tem-tab { opacity: 0; }
.w5tem-ini { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; background: rgba(255,255,255,.92); color: #1d1f22; font-size: 13px; font-weight: 700; }
.w5tem-name { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 14px; font-weight: 600; letter-spacing: .04em; white-space: nowrap; text-shadow: 0 1px 8px rgba(0,0,0,.5); }
.w5tem-card { position: absolute; left: 20px; bottom: 20px; max-width: calc(var(--ow) - 40px); box-sizing: border-box; padding: 20px 22px; border-radius: 4px; background: #fff; color: #1d1f22; box-shadow: 0 18px 40px rgba(0,0,0,.25); opacity: 0; transform: translateY(12px); transition: opacity .25s, transform .25s; pointer-events: none; }
.is-open .w5tem-card { opacity: 1; transform: none; transition: opacity .45s .35s, transform .55s .35s cubic-bezier(.2,.9,.25,1); }
.w5tem-card h3 { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 600; }
.w5tem-role { margin: 2px 0 0; font-size: 14px; font-weight: 500; color: #475569; }
.w5tem-bio { margin: 12px 0 0; max-width: 20rem; font-size: 14px; line-height: 1.6; color: #334155; }
.w5tem-card a { pointer-events: auto; display: inline-flex; align-items: center; height: 40px; margin-top: 4px; font-size: 14px; font-weight: 600; color: #1d1f22; text-decoration: underline; text-decoration-color: #94a3b8; text-underline-offset: 4px; }
.w5tem-card a:hover { text-decoration-color: #1d1f22; }
.w5tem-card a:focus-visible { outline: 2px solid #1d1f22; outline-offset: 2px; }
.w5tem-hit { position: absolute; top: 0; left: 0; bottom: 0; width: var(--c); padding: 0; border: 0; background: transparent; cursor: pointer; }
.is-open .w5tem-hit { width: var(--ow); cursor: default; }
.w5tem-hit:focus-visible { outline: 3px solid #fff; outline-offset: -6px; box-shadow: inset 0 0 0 6px #1d1f22; }
.w5tem-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
.w5tem-stage { --c: 58px; height: 640px; }
.w5tem-panel { transform: translateY(calc(var(--i) * var(--c))); border-left: 0; border-top: 1px solid rgba(255,255,255,.35); }
.w5tem-panel:first-child { border-top: 0; }
.w5tem-panel.is-after { transform: translateY(calc(100% - (var(--n) - var(--i)) * var(--c))); }
.w5tem-media { right: 0; bottom: auto; width: auto; height: var(--ow); }
.w5tem-media img { transform: translateY(calc(var(--c) / 2 - 50%)) scale(1.06); }
.w5tem-tab { right: 0; bottom: auto; width: auto; height: var(--c); flex-direction: row; justify-content: flex-start; gap: 14px; padding: 0 14px; }
.w5tem-ini { width: 34px; height: 34px; font-size: 12px; }
.w5tem-name { writing-mode: horizontal-tb; transform: none; }
.w5tem-card { left: 12px; right: 12px; bottom: calc((var(--n) - 1) * var(--c) + 12px); max-width: none; padding: 12px 16px; }
.w5tem-bio { margin-top: 6px; font-size: 13px; }
.w5tem-hit { right: 0; bottom: auto; width: auto; height: var(--c); }
.is-open .w5tem-hit { width: auto; height: var(--ow); }
}
@media (prefers-reduced-motion: reduce) {
.w5tem-panel, .w5tem-media img, .w5tem-mono, .w5tem-veil, .w5tem-tab, .w5tem-card, .is-open .w5tem-card { transition: none; }
}
</style>
<script>
(function () {
/* Change this: how long (ms) the mouse rests on a portrait strip before it opens. */
var HOVER_DELAY = 80;
var root = document.querySelector(".w5tem");
if (!root) return;
var panels = [].slice.call(root.querySelectorAll(".w5tem-panel")), timer = 0;
function open(k) {
panels.forEach(function (p, i) {
p.classList.toggle("is-open", i === k);
p.classList.toggle("is-after", i > k);
p.querySelector(".w5tem-hit").setAttribute("aria-expanded", i === k ? "true" : "false");
p.querySelector(".w5tem-card a").tabIndex = i === k ? 0 : -1;
});
}
panels.forEach(function (p, i) {
var b = p.querySelector(".w5tem-hit");
b.addEventListener("pointerenter", function (e) {
if (e.pointerType !== "mouse") return;
clearTimeout(timer);
timer = setTimeout(function () { open(i); }, HOVER_DELAY);
});
b.addEventListener("pointerleave", function () { clearTimeout(timer); });
b.addEventListener("focus", function () { open(i); });
b.addEventListener("click", function () { open(i); });
});
})();
</script>
With reduced motion: Portraits switch at once with no slide or fade, and the open bio card is shown in place.
Running cost: Opening a portrait changes transforms and opacity on four layers; there is no loop or scroll work.
- Swap people in the `PEOPLE` array or the `.w5tem-panel` blocks, and set `--n` on `.w5tem-stage` to match the count.
- Make closed strips wider or narrower with `--c`, and move the face inside each photo with `object-position` on `.w5tem-media img`.
- Remove `.w5tem-mono` if you would rather keep closed portraits in colour.
Expanding Travel Destination Photo Panels
A row of five travel photos where one route sits open and the rest wait as narrow numbered strips with their region written up the side. Resting the mouse on a strip, tabbing to it or tapping it slides the layers across so that trip opens, and its title, length and price rise in underneath. On phones the strips stack top to bottom.
<section class="w5trv">
<div class="w5trv-wrap">
<div class="w5trv-head">
<div>
<p class="w5trv-eyebrow">Saltroad Journeys</p>
<h2 class="w5trv-h2">Five slow routes for next spring</h2>
</div>
<p class="w5trv-lede">Small groups of ten, local guides and no early flights. Point at a route, tab to it or tap it to read more.</p>
</div>
<div class="w5trv-stage">
<div class="w5trv-panel is-open" style="--i:0">
<div class="w5trv-media"><img src="https://images.pexels.com/photos/13313578/pexels-photo-13313578.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="White houses on a green clifftop above a rough grey sea" loading="eager"><div class="w5trv-shade"></div><div class="w5trv-dim"></div></div>
<div class="w5trv-tab" aria-hidden="true"><span class="w5trv-num">01</span><span class="w5trv-name">Atlantic coast</span><span class="w5trv-plus">+</span></div>
<button type="button" class="w5trv-hit" aria-expanded="true" aria-controls="w5trv-cap-0"><span class="w5trv-sr">Atlantic coast: Cliff villages on foot</span></button>
<div class="w5trv-cap" id="w5trv-cap-0"><p class="w5trv-place">Atlantic coast</p><h3>Cliff villages on foot</h3><p class="w5trv-line">Harbour to harbour along the headlands, with your bags carried ahead each morning.</p><div class="w5trv-row"><span>8 nights · From $2,140</span><a href="#">See the route →</a></div></div>
</div>
<div class="w5trv-panel is-after" style="--i:1">
<div class="w5trv-media"><img src="https://images.pexels.com/photos/37818878/pexels-photo-37818878.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Tall orange sand dunes with soft shadows under a pale sky" loading="lazy"><div class="w5trv-shade"></div><div class="w5trv-dim"></div></div>
<div class="w5trv-tab" aria-hidden="true"><span class="w5trv-num">02</span><span class="w5trv-name">Sahara edge</span><span class="w5trv-plus">+</span></div>
<button type="button" class="w5trv-hit" aria-expanded="false" aria-controls="w5trv-cap-1"><span class="w5trv-sr">Sahara edge: Two nights in the sand sea</span></button>
<div class="w5trv-cap" id="w5trv-cap-1"><p class="w5trv-place">Sahara edge</p><h3>Two nights in the sand sea</h3><p class="w5trv-line">Camel trains at first light and a camp lit only by lanterns and the stars.</p><div class="w5trv-row"><span>6 nights · From $1,860</span><a href="#" tabindex="-1">See the route →</a></div></div>
</div>
<div class="w5trv-panel is-after" style="--i:2">
<div class="w5trv-media"><img src="https://images.pexels.com/photos/28283858/pexels-photo-28283858.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A turquoise lake below a rocky slope and a snowy glacier" loading="lazy"><div class="w5trv-shade"></div><div class="w5trv-dim"></div></div>
<div class="w5trv-tab" aria-hidden="true"><span class="w5trv-num">03</span><span class="w5trv-name">High Alps</span><span class="w5trv-plus">+</span></div>
<button type="button" class="w5trv-hit" aria-expanded="false" aria-controls="w5trv-cap-2"><span class="w5trv-sr">High Alps: Glacier lakes hut to hut</span></button>
<div class="w5trv-cap" id="w5trv-cap-2"><p class="w5trv-place">High Alps</p><h3>Glacier lakes hut to hut</h3><p class="w5trv-line">Mountain huts, cold green water and one long day over a high pass.</p><div class="w5trv-row"><span>7 nights · From $2,390</span><a href="#" tabindex="-1">See the route →</a></div></div>
</div>
<div class="w5trv-panel is-after" style="--i:3">
<div class="w5trv-media"><img src="https://images.pexels.com/photos/15210782/pexels-photo-15210782.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A narrow street of old houses with lanterns hanging overhead at dusk" loading="lazy"><div class="w5trv-shade"></div><div class="w5trv-dim"></div></div>
<div class="w5trv-tab" aria-hidden="true"><span class="w5trv-num">04</span><span class="w5trv-name">Old quarter</span><span class="w5trv-plus">+</span></div>
<button type="button" class="w5trv-hit" aria-expanded="false" aria-controls="w5trv-cap-3"><span class="w5trv-sr">Old quarter: Lantern towns by night</span></button>
<div class="w5trv-cap" id="w5trv-cap-3"><p class="w5trv-place">Old quarter</p><h3>Lantern towns by night</h3><p class="w5trv-line">Slow evenings in lamp-lit lanes, with a local cook as your guide.</p><div class="w5trv-row"><span>5 nights · From $1,480</span><a href="#" tabindex="-1">See the route →</a></div></div>
</div>
<div class="w5trv-panel is-after" style="--i:4">
<div class="w5trv-media"><img src="https://images.pexels.com/photos/28747444/pexels-photo-28747444.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Bright green rice terraces curving down a hillside with a small hut" loading="lazy"><div class="w5trv-shade"></div><div class="w5trv-dim"></div></div>
<div class="w5trv-tab" aria-hidden="true"><span class="w5trv-num">05</span><span class="w5trv-name">Hill country</span><span class="w5trv-plus">+</span></div>
<button type="button" class="w5trv-hit" aria-expanded="false" aria-controls="w5trv-cap-4"><span class="w5trv-sr">Hill country: Rice terraces at harvest</span></button>
<div class="w5trv-cap" id="w5trv-cap-4"><p class="w5trv-place">Hill country</p><h3>Rice terraces at harvest</h3><p class="w5trv-line">Stay with farming families and walk the green steps as the crop comes in.</p><div class="w5trv-row"><span>9 nights · From $2,020</span><a href="#" tabindex="-1">See the route →</a></div></div>
</div>
</div>
</div>
</section>
<style>
/* Change these: --c is the closed strip width, --n the number of panels,
the stage height, and the .75s slide time on .w5trv-panel. */
.w5trv { background: #efe6d8; padding: 56px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #2b2118; }
.w5trv-wrap { max-width: 1152px; margin: 0 auto; }
.w5trv-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 32px; }
.w5trv-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: #7a4f2a; }
.w5trv-h2 { margin: 12px 0 0; max-width: 36rem; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
.w5trv-lede { margin: 0; max-width: 24rem; font-size: 16px; line-height: 1.6; color: #5a4634; }
.w5trv-stage { --c: 76px; --n: 5; --ow: calc(100% - (var(--n) - 1) * var(--c)); position: relative; height: 520px; overflow: hidden; border-radius: 22px; background: #2b2118; }
.w5trv-panel { position: absolute; inset: 0; z-index: var(--i); transform: translateX(calc(var(--i) * var(--c))); transition: transform .75s cubic-bezier(.22,1,.36,1); box-shadow: -12px 0 28px rgba(24,14,4,.35); }
.w5trv-panel.is-after { transform: translateX(calc(100% - (var(--n) - var(--i)) * var(--c))); }
.w5trv-media { position: absolute; top: 0; left: 0; bottom: 0; width: var(--ow); overflow: hidden; background: #3a2c20; }
.w5trv-media img { display: block; width: 100%; height: 100%; object-fit: cover; transform: translateX(calc(var(--c) / 2 - 50%)) scale(1.1); transition: transform .9s cubic-bezier(.22,1,.36,1); }
.is-open .w5trv-media img { transform: none; }
.w5trv-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(26,16,6,.85), rgba(26,16,6,.15) 55%, rgba(26,16,6,0)); }
.w5trv-dim { position: absolute; inset: 0; background: rgba(34,22,10,.5); transition: opacity .5s; }
.is-open .w5trv-dim { opacity: 0; }
.w5trv-tab { position: absolute; top: 0; left: 0; bottom: 0; width: var(--c); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 24px 0; box-sizing: border-box; color: #f8efe2; transition: opacity .3s; pointer-events: none; }
.is-open .w5trv-tab { opacity: 0; }
.w5trv-num { font-size: 12px; font-weight: 600; }
.w5trv-plus { font-size: 20px; line-height: 1; }
.w5trv-name { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 15px; font-weight: 600; letter-spacing: .06em; white-space: nowrap; }
.w5trv-cap { position: absolute; left: 0; bottom: 0; width: var(--ow); box-sizing: border-box; padding: 32px; color: #fbf6ee; opacity: 0; transform: translateY(16px); transition: opacity .3s, transform .3s; pointer-events: none; }
.is-open .w5trv-cap { opacity: 1; transform: none; transition: opacity .5s .3s, transform .6s .3s cubic-bezier(.22,1,.36,1); }
.w5trv-place { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #f2c98c; }
.w5trv-cap h3 { margin: 8px 0 0; font-size: clamp(24px, 3vw, 30px); line-height: 1.15; font-weight: 600; }
.w5trv-line { margin: 8px 0 0; max-width: 28rem; font-size: 16px; line-height: 1.6; color: #efe3d2; }
.w5trv-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 20px; font-size: 14px; color: #efe3d2; }
.w5trv-row a { pointer-events: auto; display: inline-flex; align-items: center; height: 40px; padding: 0 20px; border-radius: 999px; background: #fbf6ee; color: #2b2118; font-weight: 600; text-decoration: none; }
.w5trv-row a:hover { background: #fff; }
.w5trv-row a:focus-visible { outline: 2px solid #f2c98c; outline-offset: 3px; }
.w5trv-hit { position: absolute; top: 0; left: 0; bottom: 0; width: var(--c); padding: 0; border: 0; background: transparent; cursor: pointer; }
.is-open .w5trv-hit { width: var(--ow); cursor: default; }
.w5trv-hit:focus-visible { outline: 3px solid #f2c98c; outline-offset: -7px; border-radius: 16px; }
.w5trv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
.w5trv-stage { --c: 60px; height: 600px; }
.w5trv-panel { transform: translateY(calc(var(--i) * var(--c))); box-shadow: 0 -12px 28px rgba(24,14,4,.35); }
.w5trv-panel.is-after { transform: translateY(calc(100% - (var(--n) - var(--i)) * var(--c))); }
.w5trv-media { right: 0; bottom: auto; width: auto; height: var(--ow); }
.w5trv-media img { transform: translateY(calc(var(--c) / 2 - 50%)) scale(1.1); }
.w5trv-tab { right: 0; bottom: auto; width: auto; height: var(--c); flex-direction: row; padding: 0 20px; }
.w5trv-name { writing-mode: horizontal-tb; transform: none; }
.w5trv-cap { width: auto; right: 0; bottom: calc((var(--n) - 1) * var(--c)); padding: 22px; }
.w5trv-hit { right: 0; bottom: auto; width: auto; height: var(--c); }
.is-open .w5trv-hit { width: auto; height: var(--ow); }
}
@media (prefers-reduced-motion: reduce) {
.w5trv-panel, .w5trv-media img, .w5trv-cap, .is-open .w5trv-cap, .w5trv-tab, .w5trv-dim { transition: none; }
}
</style>
<script>
(function () {
/* Change this: how long (ms) the mouse rests on a strip before it opens. */
var HOVER_DELAY = 70;
var root = document.querySelector(".w5trv");
if (!root) return;
var panels = [].slice.call(root.querySelectorAll(".w5trv-panel")), timer = 0;
function open(k) {
panels.forEach(function (p, i) {
p.classList.toggle("is-open", i === k);
p.classList.toggle("is-after", i > k);
p.querySelector(".w5trv-hit").setAttribute("aria-expanded", i === k ? "true" : "false");
p.querySelector(".w5trv-cap a").tabIndex = i === k ? 0 : -1;
});
}
panels.forEach(function (p, i) {
var b = p.querySelector(".w5trv-hit");
b.addEventListener("pointerenter", function (e) {
if (e.pointerType !== "mouse") return;
clearTimeout(timer);
timer = setTimeout(function () { open(i); }, HOVER_DELAY);
});
b.addEventListener("pointerleave", function () { clearTimeout(timer); });
b.addEventListener("focus", function () { open(i); });
b.addEventListener("click", function () { open(i); });
});
})();
</script>
With reduced motion: Panels open instantly on hover, focus or tap with no sliding, and every caption stays readable.
Running cost: Only transforms and opacity change when a panel opens, and nothing runs between interactions.
- Change the closed strip width with `--c` on `.w5trv-stage`, and keep `--n` equal to the number of panels.
- Edit trips in the `TRIPS` array (React) or the repeated `.w5trv-panel` blocks (HTML), raising `--i` by one for each.
- Slow or speed the slide with the `.75s` on `.w5trv-panel`; the caption waits `.3s` before it fades in.
Interior Room Gallery With Captions After Settle
Five rooms of a guest house laid out as rounded photo cards with slim gaps between them. Choosing a room slides the cards aside, and only once they have come to rest does a small caption card fade in with the room name, a line about it and its materials, each line arriving a beat after the last. On phones the cards stack top to bottom.
<section class="w5rom">
<div class="w5rom-wrap">
<div class="w5rom-head">
<div><p class="w5rom-eyebrow">Linden House · Stays</p><h2 class="w5rom-h2">Walk through the house</h2></div>
<p class="w5rom-lede">A restored 1890s townhouse for up to four guests. Open a room to see what it is made of.</p>
</div>
<div class="w5rom-stage">
<div class="w5rom-panel is-open is-settled" style="--i:0">
<div class="w5rom-media"><img src="https://images.pexels.com/photos/3334699/pexels-photo-3334699.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A sunlit corner with a pale sofa, potted plants and window shadows on the wall" loading="eager"><div class="w5rom-veil"></div></div>
<div class="w5rom-tab" aria-hidden="true"><span class="w5rom-name">Garden room</span></div>
<button type="button" class="w5rom-hit" aria-expanded="true" aria-controls="w5rom-cap-0"><span class="w5rom-sr">Garden room</span></button>
<div class="w5rom-cap" id="w5rom-cap-0"><h3>Garden room</h3><p class="w5rom-line">Morning sun, a deep sofa and the ferns we cannot stop buying.</p><p class="w5rom-spec">Lime plaster · Linen · South light</p></div>
</div>
<div class="w5rom-panel is-after" style="--i:1">
<div class="w5rom-media"><img src="https://images.pexels.com/photos/7303782/pexels-photo-7303782.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A small kitchen with wooden cabinets, a pale chair and a vase of dried leaves" loading="lazy"><div class="w5rom-veil"></div></div>
<div class="w5rom-tab" aria-hidden="true"><span class="w5rom-name">Kitchen</span></div>
<button type="button" class="w5rom-hit" aria-expanded="false" aria-controls="w5rom-cap-1"><span class="w5rom-sr">Kitchen</span></button>
<div class="w5rom-cap" id="w5rom-cap-1"><h3>Kitchen</h3><p class="w5rom-line">Oak fronts, a proper kettle and room for two people to cook.</p><p class="w5rom-spec">Oiled oak · Terrazzo · Brass</p></div>
</div>
<div class="w5rom-panel is-after" style="--i:2">
<div class="w5rom-media"><img src="https://images.pexels.com/photos/4153150/pexels-photo-4153150.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="An unmade bed with white sheets beneath a tall window" loading="lazy"><div class="w5rom-veil"></div></div>
<div class="w5rom-tab" aria-hidden="true"><span class="w5rom-name">Main bedroom</span></div>
<button type="button" class="w5rom-hit" aria-expanded="false" aria-controls="w5rom-cap-2"><span class="w5rom-sr">Main bedroom</span></button>
<div class="w5rom-cap" id="w5rom-cap-2"><h3>Main bedroom</h3><p class="w5rom-line">Heavy curtains, a firm mattress and nothing that hums at night.</p><p class="w5rom-spec">Washed cotton · Wool · Blackout</p></div>
</div>
<div class="w5rom-panel is-after" style="--i:3">
<div class="w5rom-media"><img src="https://images.pexels.com/photos/10919439/pexels-photo-10919439.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A black freestanding bathtub in a stone-coloured room lit from above" loading="lazy"><div class="w5rom-veil"></div></div>
<div class="w5rom-tab" aria-hidden="true"><span class="w5rom-name">Bathroom</span></div>
<button type="button" class="w5rom-hit" aria-expanded="false" aria-controls="w5rom-cap-3"><span class="w5rom-sr">Bathroom</span></button>
<div class="w5rom-cap" id="w5rom-cap-3"><h3>Bathroom</h3><p class="w5rom-line">A deep tub under a soft ceiling light, with towels warmed on the rail.</p><p class="w5rom-spec">Microcement · Black enamel · Teak</p></div>
</div>
<div class="w5rom-panel is-after" style="--i:4">
<div class="w5rom-media"><img src="https://images.pexels.com/photos/34438566/pexels-photo-34438566.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A tall plant beside bookshelves in warm afternoon light" loading="lazy"><div class="w5rom-veil"></div></div>
<div class="w5rom-tab" aria-hidden="true"><span class="w5rom-name">Reading nook</span></div>
<button type="button" class="w5rom-hit" aria-expanded="false" aria-controls="w5rom-cap-4"><span class="w5rom-sr">Reading nook</span></button>
<div class="w5rom-cap" id="w5rom-cap-4"><h3>Reading nook</h3><p class="w5rom-line">A chair, a lamp and three shelves of novels left by past guests.</p><p class="w5rom-spec">Walnut · Wool rug · Paper lamp</p></div>
</div>
</div>
</div>
</section>
<style>
/* Change these: --c is the closed card width, --g the gap between cards,
--n the number of rooms, the stage height, and the .8s slide on .w5rom-panel. */
.w5rom { background: #faf7f2; padding: 56px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #2e2a25; }
.w5rom-wrap { max-width: 1152px; margin: 0 auto; }
.w5rom-head { display: grid; gap: 16px; margin-bottom: 32px; }
@media (min-width: 768px) { .w5rom-head { grid-template-columns: 1fr 1fr; align-items: end; } .w5rom-lede { justify-self: end; } }
.w5rom-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: #7a5c34; }
.w5rom-h2 { margin: 12px 0 0; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
.w5rom-lede { margin: 0; max-width: 28rem; font-size: 16px; line-height: 1.6; color: #5b5248; }
.w5rom-cap h3 { margin: 0; font-size: 18px; font-weight: 600; }
.w5rom-line { margin: 4px 0 0; font-size: 14px; line-height: 1.6; color: #4d453c; }
.w5rom-spec { margin: 12px 0 0; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #7a5c34; }
.w5rom-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.w5rom-stage{--c:70px;--g:10px;--n:5;--ow:calc(100% - (var(--n) - 1) * var(--c));position:relative;height:540px;overflow:hidden;background:#faf7f2}
.w5rom-panel{position:absolute;inset:0;z-index:var(--i);background:#faf7f2;transform:translateX(calc(var(--i) * var(--c)));transition:transform .8s cubic-bezier(.3,1,.3,1)}
.w5rom-panel.is-after{transform:translateX(calc(100% - (var(--n) - var(--i)) * var(--c)))}
.w5rom-media{position:absolute;top:0;bottom:0;left:var(--g);width:calc(var(--ow) - var(--g));overflow:hidden;border-radius:14px;background:#e6ddd0}
.w5rom-panel:first-child .w5rom-media{left:0}
.w5rom-media img{display:block;width:100%;height:100%;object-fit:cover;transform:translateX(calc(var(--c) / 2 - 50%)) scale(1.06);transition:transform 1s cubic-bezier(.3,1,.3,1)}
.is-open .w5rom-media img{transform:none}
.w5rom-veil{position:absolute;inset:0;background:rgba(46,42,37,.28);transition:opacity .5s}
.is-open .w5rom-veil{opacity:0}
.w5rom-tab{position:absolute;top:0;bottom:0;left:var(--g);width:calc(var(--c) - var(--g));display:flex;align-items:flex-end;justify-content:center;padding-bottom:22px;box-sizing:border-box;color:#fff;pointer-events:none;transition:opacity .3s}
.w5rom-panel:first-child .w5rom-tab{left:0;width:var(--c)}
.is-open .w5rom-tab{opacity:0}
.w5rom-name{writing-mode:vertical-rl;transform:rotate(180deg);font-size:14px;font-weight:600;letter-spacing:.06em;white-space:nowrap;text-shadow:0 1px 10px rgba(0,0,0,.45)}
.w5rom-cap{position:absolute;left:calc(var(--g) + 20px);top:20px;max-width:min(360px,calc(var(--ow) - var(--g) - 40px));box-sizing:border-box;padding:18px 20px;border-radius:10px;background:rgba(250,247,242,.94);color:#2e2a25;pointer-events:none;box-shadow:0 12px 30px rgba(46,42,37,.18);opacity:0;transform:translateY(-10px);transition:opacity .2s,transform .2s}
.w5rom-panel:first-child .w5rom-cap{left:20px}
.w5rom-cap>*{opacity:0;transform:translateY(6px);transition:opacity .2s,transform .2s}
.is-settled .w5rom-cap,.is-settled .w5rom-cap>*{opacity:1;transform:none;transition:opacity .45s,transform .55s cubic-bezier(.22,1,.36,1)}
.is-settled .w5rom-cap>:nth-child(2){transition-delay:.08s}
.is-settled .w5rom-cap>:nth-child(3){transition-delay:.16s}
.w5rom-hit{position:absolute;top:0;bottom:0;left:0;width:var(--c);padding:0;border:0;background:transparent;cursor:pointer}
.is-open .w5rom-hit{width:var(--ow);cursor:default}
.w5rom-hit:focus-visible{outline:3px solid #8a6a3f;outline-offset:-4px;border-radius:16px}
@media (max-width:640px){
.w5rom-stage{--c:58px;height:620px}
.w5rom-panel{transform:translateY(calc(var(--i) * var(--c)))}
.w5rom-panel.is-after{transform:translateY(calc(100% - (var(--n) - var(--i)) * var(--c)))}
.w5rom-media{left:0;right:0;top:var(--g);bottom:auto;width:auto;height:calc(var(--ow) - var(--g))}
.w5rom-panel:first-child .w5rom-media{top:0}
.w5rom-media img{transform:translateY(calc(var(--c) / 2 - 50%)) scale(1.06)}
.w5rom-tab,.w5rom-panel:first-child .w5rom-tab{left:0;right:0;top:var(--g);bottom:auto;width:auto;height:calc(var(--c) - var(--g));align-items:center;justify-content:flex-start;padding:0 18px}
.w5rom-panel:first-child .w5rom-tab{top:0;height:var(--c)}
.w5rom-name{writing-mode:horizontal-tb;transform:none}
.w5rom-cap,.w5rom-panel:first-child .w5rom-cap{left:12px;right:12px;top:calc(var(--g) + 12px);max-width:none}
.w5rom-hit{right:0;bottom:auto;width:auto;height:var(--c)}
.is-open .w5rom-hit{width:auto;height:var(--ow)}
}
@media (prefers-reduced-motion:reduce){.w5rom-panel,.w5rom-media img,.w5rom-veil,.w5rom-tab,.w5rom-cap,.w5rom-cap>*,.is-settled .w5rom-cap,.is-settled .w5rom-cap>*{transition:none}}
</style>
<script>
(function () {
/* Change these: hover delay before a card opens, and the backstop (ms) after which
the caption shows even if no transitionend event arrives. */
var HOVER_DELAY = 80, SETTLE_BACKSTOP = 900;
var root = document.querySelector(".w5rom");
if (!root) return;
var stage = root.querySelector(".w5rom-stage");
var panels = [].slice.call(root.querySelectorAll(".w5rom-panel")), cur = 0, timer = 0, backstop = 0;
var reduce = window.matchMedia("(prefers-reduced-motion: reduce)");
function settle() { clearTimeout(backstop); panels[cur].classList.add("is-settled"); }
function open(k) {
if (k === cur) return;
cur = k;
panels.forEach(function (p, i) {
p.classList.toggle("is-open", i === k);
p.classList.toggle("is-after", i > k);
p.classList.remove("is-settled");
p.querySelector(".w5rom-hit").setAttribute("aria-expanded", i === k ? "true" : "false");
});
clearTimeout(backstop);
if (reduce.matches) settle(); else backstop = setTimeout(settle, SETTLE_BACKSTOP);
}
stage.addEventListener("transitionend", function (e) {
if (e.propertyName === "transform" && e.target.classList.contains("w5rom-panel")) settle();
});
panels.forEach(function (p, i) {
var b = p.querySelector(".w5rom-hit");
b.addEventListener("pointerenter", function (e) {
if (e.pointerType !== "mouse") return;
clearTimeout(timer);
timer = setTimeout(function () { open(i); }, HOVER_DELAY);
});
b.addEventListener("pointerleave", function () { clearTimeout(timer); });
b.addEventListener("focus", function () { open(i); });
b.addEventListener("click", function () { open(i); });
});
})();
</script>
With reduced motion: Rooms switch at once and their captions appear immediately, with no slide or staggered fade.
Running cost: One class change per choice moves the cards with transforms, and a single transitionend listener reveals the caption.
- Change the gap between cards with `--g` and the closed card width with `--c` on `.w5rom-stage`.
- Make captions wait longer or shorter by changing the `.8s` slide on `.w5rom-panel`; the caption follows its end, with `SETTLE_BACKSTOP` as the upper limit.
- Edit rooms in `ROOMS`, keeping the materials line short enough for one row.
Vertical Photo Strip Accordion for Trail Guides
Four hiking routes stacked as tinted photo rows, each showing its name, length and grade. The open row grows into a full photograph with a short description, three trail numbers and a map link, while the others slide down to wait underneath. Because it never turns sideways, the same layout works unchanged on a narrow phone screen.
<section class="w5trl">
<div class="w5trl-wrap">
<div>
<p class="w5trl-eyebrow">Fernway Trail Guides</p>
<h2 class="w5trl-h2">Pick a trail for Saturday</h2>
<p class="w5trl-lede">Four routes from the same car park, from an easy stroll to a full day on the crest. Every one is walked by a guide the week before.</p>
<ul class="w5trl-list"><li>Meet 8:00 at the Fernway hut</li><li>Maps and poles lent free</li></ul>
</div>
<div class="w5trl-stage">
<div class="w5trl-panel is-open" style="--i:0">
<div class="w5trl-media"><img src="https://images.pexels.com/photos/32375565/pexels-photo-32375565.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A walker on a rocky path below a steep slope of dark conifers" loading="eager"><div class="w5trl-shade"></div><div class="w5trl-bar"></div></div>
<div class="w5trl-row" aria-hidden="true"><span class="w5trl-name">Spruce Ridge Loop</span><span class="w5trl-meta">9.4 km · Moderate<svg width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8"><path d="m5 8 5 5 5-5"/></svg></span></div>
<button type="button" class="w5trl-hit" aria-expanded="true" aria-controls="w5trl-cap-0"><span class="w5trl-sr">Spruce Ridge Loop, 9.4 km, Moderate</span></button>
<div class="w5trl-cap" id="w5trl-cap-0"><p class="w5trl-grade">Moderate</p><h3>Spruce Ridge Loop</h3><p class="w5trl-line">A shaded climb through old spruce to a stony ridge with long views east.</p><dl class="w5trl-stats"><div><dt>Distance</dt><dd>9.4 km</dd></div><div><dt>Climb</dt><dd>410 m</dd></div><div><dt>Time</dt><dd>3 h 30</dd></div></dl><a href="#">Get the route map</a></div>
</div>
<div class="w5trl-panel is-after" style="--i:1">
<div class="w5trl-media"><img src="https://images.pexels.com/photos/29176381/pexels-photo-29176381.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A runner on a leafy woodland trail between tall bare trees" loading="lazy"><div class="w5trl-shade"></div><div class="w5trl-bar"></div></div>
<div class="w5trl-row" aria-hidden="true"><span class="w5trl-name">Birch Hollow</span><span class="w5trl-meta">6.1 km · Easy<svg width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8"><path d="m5 8 5 5 5-5"/></svg></span></div>
<button type="button" class="w5trl-hit" aria-expanded="false" aria-controls="w5trl-cap-1"><span class="w5trl-sr">Birch Hollow, 6.1 km, Easy</span></button>
<div class="w5trl-cap" id="w5trl-cap-1"><p class="w5trl-grade">Easy</p><h3>Birch Hollow</h3><p class="w5trl-line">Flat and friendly, through bare birch woods that glow in low autumn sun.</p><dl class="w5trl-stats"><div><dt>Distance</dt><dd>6.1 km</dd></div><div><dt>Climb</dt><dd>120 m</dd></div><div><dt>Time</dt><dd>2 h</dd></div></dl><a href="#" tabindex="-1">Get the route map</a></div>
</div>
<div class="w5trl-panel is-after" style="--i:2">
<div class="w5trl-media"><img src="https://images.pexels.com/photos/38246300/pexels-photo-38246300.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A green path framed by trees leading toward a snow-capped mountain" loading="lazy"><div class="w5trl-shade"></div><div class="w5trl-bar"></div></div>
<div class="w5trl-row" aria-hidden="true"><span class="w5trl-name">Glacier View Saddle</span><span class="w5trl-meta">14.8 km · Hard<svg width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8"><path d="m5 8 5 5 5-5"/></svg></span></div>
<button type="button" class="w5trl-hit" aria-expanded="false" aria-controls="w5trl-cap-2"><span class="w5trl-sr">Glacier View Saddle, 14.8 km, Hard</span></button>
<div class="w5trl-cap" id="w5trl-cap-2"><p class="w5trl-grade">Hard</p><h3>Glacier View Saddle</h3><p class="w5trl-line">A long day up through meadow to a saddle facing the snow peak itself.</p><dl class="w5trl-stats"><div><dt>Distance</dt><dd>14.8 km</dd></div><div><dt>Climb</dt><dd>980 m</dd></div><div><dt>Time</dt><dd>6 h</dd></div></dl><a href="#" tabindex="-1">Get the route map</a></div>
</div>
<div class="w5trl-panel is-after" style="--i:3">
<div class="w5trl-media"><img src="https://images.pexels.com/photos/27769494/pexels-photo-27769494.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Three hikers with packs climbing a grassy slope toward blue mountains" loading="lazy"><div class="w5trl-shade"></div><div class="w5trl-bar"></div></div>
<div class="w5trl-row" aria-hidden="true"><span class="w5trl-name">Summit Traverse</span><span class="w5trl-meta">18.2 km · Hard<svg width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8"><path d="m5 8 5 5 5-5"/></svg></span></div>
<button type="button" class="w5trl-hit" aria-expanded="false" aria-controls="w5trl-cap-3"><span class="w5trl-sr">Summit Traverse, 18.2 km, Hard</span></button>
<div class="w5trl-cap" id="w5trl-cap-3"><p class="w5trl-grade">Hard</p><h3>Summit Traverse</h3><p class="w5trl-line">Our guided route along the crest, with poles, a radio and a hot lunch.</p><dl class="w5trl-stats"><div><dt>Distance</dt><dd>18.2 km</dd></div><div><dt>Climb</dt><dd>1,240 m</dd></div><div><dt>Time</dt><dd>8 h</dd></div></dl><a href="#" tabindex="-1">Get the route map</a></div>
</div>
</div>
</div>
</section>
<style>
/* Change these: --c is the closed row height, --n the number of trails,
the stage height, and the .7s slide time on .w5trl-panel. */
.w5trl { background: #11241a; padding: 56px 16px; font-family: ui-sans-serif, system-ui, sans-serif; color: #f1f6ef; }
.w5trl-wrap { max-width: 1024px; margin: 0 auto; display: grid; gap: 40px; }
@media (min-width: 768px) { .w5trl-wrap { grid-template-columns: minmax(0, 4fr) minmax(0, 6fr); align-items: center; } }
.w5trl-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: #a9d39a; }
.w5trl-h2 { margin: 12px 0 0; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
.w5trl-lede { margin: 16px 0 0; max-width: 24rem; font-size: 16px; line-height: 1.6; color: #c5d6c3; }
.w5trl-list { margin: 24px 0 0; padding: 0; list-style: none; font-size: 14px; color: #c5d6c3; }
.w5trl-list li { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.w5trl-list li::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: #a9d39a; }
.w5trl-stage { --c: 64px; --n: 4; --ow: calc(100% - (var(--n) - 1) * var(--c)); position: relative; height: 660px; overflow: hidden; border-radius: 18px; background: #0b1811; box-shadow: 0 30px 60px -30px rgba(0,0,0,.6); }
.w5trl-panel { position: absolute; inset: 0; z-index: var(--i); transform: translateY(calc(var(--i) * var(--c))); transition: transform .7s cubic-bezier(.22,1,.36,1); }
.w5trl-panel.is-after { transform: translateY(calc(100% - (var(--n) - var(--i)) * var(--c))); }
.w5trl-media { position: absolute; top: 0; left: 0; right: 0; height: var(--ow); overflow: hidden; background: #1a3326; }
.w5trl-media img { display: block; width: 100%; height: 100%; object-fit: cover; transform: translateY(calc(var(--c) / 2 - 50%)) scale(1.08); transition: transform .9s cubic-bezier(.22,1,.36,1); }
.is-open .w5trl-media img { transform: none; }
.w5trl-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(8,20,13,.95), rgba(8,20,13,.78) 42%, rgba(8,20,13,0) 78%); }
.w5trl-bar { position: absolute; inset: 0; background: rgba(17,38,27,.72); border-top: 1px solid rgba(225,238,226,.14); transition: opacity .45s; }
.is-open .w5trl-bar { opacity: 0; }
.w5trl-row { position: absolute; top: 0; left: 0; right: 0; height: var(--c); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 22px; color: #e8f0e6; pointer-events: none; transition: opacity .3s; }
.is-open .w5trl-row { opacity: 0; }
.w5trl-name { font-size: 16px; font-weight: 600; }
.w5trl-meta { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #c5d6c3; white-space: nowrap; }
.w5trl-cap { position: absolute; left: 0; right: 0; bottom: calc((var(--n) - 1) * var(--c)); padding: 24px; color: #f1f6ef; opacity: 0; transform: translateY(14px); transition: opacity .25s, transform .25s; pointer-events: none; }
.is-open .w5trl-cap { opacity: 1; transform: none; transition: opacity .45s .3s, transform .6s .3s cubic-bezier(.22,1,.36,1); }
.w5trl-grade { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #a9d39a; }
.w5trl-cap h3 { margin: 4px 0 0; font-size: 24px; line-height: 1.2; font-weight: 600; }
.w5trl-line { margin: 8px 0 0; max-width: 28rem; font-size: 14px; line-height: 1.6; color: #d6e3d3; }
.w5trl-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 24rem; margin: 16px 0 0; font-size: 14px; }
.w5trl-stats dt { font-size: 12px; color: #b8ccb5; }
.w5trl-stats dd { margin: 0; font-weight: 600; }
.w5trl-cap a { pointer-events: auto; display: inline-flex; align-items: center; height: 40px; margin-top: 16px; padding: 0 20px; border-radius: 999px; background: #a9d39a; color: #0b1811; font-size: 14px; font-weight: 600; text-decoration: none; }
.w5trl-cap a:hover { background: #c2e5b5; }
.w5trl-cap a:focus-visible { outline: 2px solid #e8f0e6; outline-offset: 3px; }
.w5trl-hit { position: absolute; top: 0; left: 0; right: 0; height: var(--c); padding: 0; border: 0; background: transparent; cursor: pointer; }
.is-open .w5trl-hit { height: var(--ow); cursor: default; }
.w5trl-hit:focus-visible { outline: 3px solid #b9e4a8; outline-offset: -6px; border-radius: 12px; }
.w5trl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) { .w5trl-stage { --c: 60px; height: 580px; } .w5trl-cap { padding: 18px; } }
@media (prefers-reduced-motion: reduce) {
.w5trl-panel, .w5trl-media img, .w5trl-bar, .w5trl-row, .w5trl-cap, .is-open .w5trl-cap { transition: none; }
}
</style>
<script>
(function () {
/* Change this: how long (ms) the mouse rests on a row before it opens. */
var HOVER_DELAY = 90;
var root = document.querySelector(".w5trl");
if (!root) return;
var panels = [].slice.call(root.querySelectorAll(".w5trl-panel")), timer = 0;
function open(k) {
panels.forEach(function (p, i) {
p.classList.toggle("is-open", i === k);
p.classList.toggle("is-after", i > k);
p.querySelector(".w5trl-hit").setAttribute("aria-expanded", i === k ? "true" : "false");
p.querySelector(".w5trl-cap a").tabIndex = i === k ? 0 : -1;
});
}
panels.forEach(function (p, i) {
var b = p.querySelector(".w5trl-hit");
b.addEventListener("pointerenter", function (e) {
if (e.pointerType !== "mouse") return;
clearTimeout(timer);
timer = setTimeout(function () { open(i); }, HOVER_DELAY);
});
b.addEventListener("pointerleave", function () { clearTimeout(timer); });
b.addEventListener("focus", function () { open(i); });
b.addEventListener("click", function () { open(i); });
});
})();
</script>
With reduced motion: Rows open in one step without sliding, and the trail details are shown straight away.
Running cost: A row change moves four layers with transforms and fades two overlays; nothing runs in between.
- Change the closed row height with `--c` on `.w5trl-stage`, and the open photo grows to fill whatever is left of the stage height.
- Lighten or darken the closed tint with the alpha in `.w5trl-bar`'s background.
- Add or remove trails in `TRAILS`, then set `--n` to the new count.
Performance notes
Each panel is a full-size layer moved with translate, with its image kept the same size and only shifted, so nothing is re-measured or stretched while it opens. That is why these stay smooth even with large photos.
Images are sized to the open state and lazy-loaded when the gallery is below the fold. Captions fade with opacity after the panel settles instead of animating their own size.
Questions
How do expanding cards work in CSS?
The common version sets flex: 1 on every panel and a larger flex value on the active one, then transitions it. It is simple but animates layout. The transform-based approach used here gives the same look with less work for the browser.
Can expanding panels be used with a keyboard?
Yes, when each panel is a real button or link. Here focusing a panel opens it, the open panel is marked with aria-expanded or aria-current, and arrow keys move between panels in the versions that act like tabs.
What happens on a phone?
A row of narrow strips is too cramped on a small screen, so the panels stack vertically and the tapped one opens to show its photo and caption. No hover is needed.
How many panels should I use?
Four to six. With more, each closed panel becomes too thin to show anything recognisable, and people stop scanning the row.
More collections: CSS Hover Effects and Magnetic Buttons, Stacking Cards on Scroll, Custom Cursor Effects in CSS and JavaScript. All galleries and carousels. Build your site free to have a full site built around them.
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App