Skip to the main content

Scroll-snap Carousel

Free Media

A row of slides that snaps into place with CSS only and moves by touch, wheel, keyboard or jump links, with no script.

Checked on 3 December 2026 in Chrome 143.0.7499.169: 12 automated checks. What the checks are

Preview and code

HTML

<section class="scs" aria-labelledby="scs-title">
  <h2 id="scs-title" class="scs__heading">Scroll-snap carousel</h2>
  <p class="scs__lead">Swipe, scroll or press the arrow keys. Each slide snaps into place.</p>
  <div class="scs__track" id="scs-track" role="region" aria-label="Example slides" tabindex="0">
    <ul class="scs__slides">
      <li class="scs__slide" id="scs-slide-1">
        <figure class="scs__fig">
          <svg class="scs__art" viewBox="0 0 320 150" preserveAspectRatio="xMidYMid slice" aria-hidden="true" focusable="false"><rect width="320" height="150" fill="#d9e4ff"/><circle cx="70" cy="60" r="34" fill="#4338ca"/><circle cx="150" cy="95" r="52" fill="#7a7fe6"/><circle cx="240" cy="55" r="26" fill="#f5b546"/><rect x="0" y="128" width="320" height="22" fill="#2a2394"/></svg>
          <figcaption class="scs__cap"><span class="scs__count">1 of 5</span><strong class="scs__name">Shapes</strong><span class="scs__desc">Overlapping circles on a quiet ground.</span></figcaption>
        </figure>
      </li>
      <li class="scs__slide" id="scs-slide-2">
        <figure class="scs__fig">
          <svg class="scs__art" viewBox="0 0 320 150" preserveAspectRatio="xMidYMid slice" aria-hidden="true" focusable="false"><rect width="320" height="150" fill="#dff3ea"/><path d="M0 90c40-30 80-30 120 0s80 30 120 0 60-20 80-8v68H0z" fill="#2a9d78"/><path d="M0 115c40-24 80-24 120 0s80 24 120 0 60-14 80-4v39H0z" fill="#157a5a"/><circle cx="256" cy="38" r="20" fill="#f08a4b"/></svg>
          <figcaption class="scs__cap"><span class="scs__count">2 of 5</span><strong class="scs__name">Waves</strong><span class="scs__desc">Two layers of soft curves.</span></figcaption>
        </figure>
      </li>
      <li class="scs__slide" id="scs-slide-3">
        <figure class="scs__fig">
          <svg class="scs__art" viewBox="0 0 320 150" preserveAspectRatio="xMidYMid slice" aria-hidden="true" focusable="false"><rect width="320" height="150" fill="#fde9dc"/><path d="M0 150L70 60l50 60 40-44 60 74z" fill="#d9632b"/><path d="M110 150l70-84 50 54 90-4v34z" fill="#a8441a"/><circle cx="60" cy="32" r="16" fill="#fff"/></svg>
          <figcaption class="scs__cap"><span class="scs__count">3 of 5</span><strong class="scs__name">Peaks</strong><span class="scs__desc">Flat triangles and a pale sun.</span></figcaption>
        </figure>
      </li>
      <li class="scs__slide" id="scs-slide-4">
        <figure class="scs__fig">
          <svg class="scs__art" viewBox="0 0 320 150" preserveAspectRatio="xMidYMid slice" aria-hidden="true" focusable="false"><rect width="320" height="150" fill="#e8e3fa"/><rect x="40" y="36" width="64" height="64" rx="14" fill="#6d5bd6"/><rect x="124" y="56" width="64" height="64" rx="14" fill="#9b8cf0"/><rect x="208" y="26" width="64" height="64" rx="14" fill="#4338ca"/><rect x="40" y="122" width="232" height="10" rx="5" fill="#4338ca"/></svg>
          <figcaption class="scs__cap"><span class="scs__count">4 of 5</span><strong class="scs__name">Blocks</strong><span class="scs__desc">Rounded squares on a shared line.</span></figcaption>
        </figure>
      </li>
      <li class="scs__slide" id="scs-slide-5">
        <figure class="scs__fig">
          <svg class="scs__art" viewBox="0 0 320 150" preserveAspectRatio="xMidYMid slice" aria-hidden="true" focusable="false"><rect width="320" height="150" fill="#dcf0f7"/><circle cx="160" cy="75" r="56" fill="none" stroke="#1d7fa3" stroke-width="14"/><circle cx="160" cy="75" r="28" fill="none" stroke="#f5b546" stroke-width="12"/><circle cx="160" cy="75" r="8" fill="#1d7fa3"/></svg>
          <figcaption class="scs__cap"><span class="scs__count">5 of 5</span><strong class="scs__name">Rings</strong><span class="scs__desc">Concentric circles with a bright core.</span></figcaption>
        </figure>
      </li>
    </ul>
  </div>
  <nav class="scs__jump" aria-label="Jump to a slide">
    <a class="scs__dot" href="#scs-slide-1"><span class="scs__dot-text">Slide 1</span></a>
    <a class="scs__dot" href="#scs-slide-2"><span class="scs__dot-text">Slide 2</span></a>
    <a class="scs__dot" href="#scs-slide-3"><span class="scs__dot-text">Slide 3</span></a>
    <a class="scs__dot" href="#scs-slide-4"><span class="scs__dot-text">Slide 4</span></a>
    <a class="scs__dot" href="#scs-slide-5"><span class="scs__dot-text">Slide 5</span></a>
  </nav>
</section>

CSS

.scs {
  --scs-surface: #ffffff;
  --scs-fg: #1b2032;
  --scs-muted: #4a5266;
  --scs-line: #d3d8e6;
  --scs-soft: #eceeff;
  --scs-accent: #4338ca;
  --scs-on-accent: #ffffff;
  --scs-ring: #4338ca;
  box-sizing: border-box;
  width: min(100%, 40rem);
  padding: 1.25rem 0 1.25rem 1.25rem;
  color: var(--scs-fg);
  background: var(--scs-surface);
  border: 1px solid var(--scs-line);
  border-radius: 16px;
  box-shadow: 0 10px 30px -18px rgba(27, 32, 50, 0.4);
}
.scs *, .scs *::before, .scs *::after { box-sizing: border-box; }
.scs__heading { margin: 0; padding-right: 1.25rem; font-size: 1.25rem; letter-spacing: -0.01em; }
.scs__lead { margin: 0.3rem 0 1rem; padding-right: 1.25rem; color: var(--scs-muted); font-size: 0.9375rem; line-height: 1.5; }
.scs__track {
  width: 0;
  min-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 0;
  padding-bottom: 0.9rem;
  border-radius: 12px;
  scrollbar-color: var(--scs-accent) var(--scs-soft);
}
.scs__track:focus-visible { outline: 3px solid var(--scs-ring); outline-offset: 3px; }
.scs__slides {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(78%, 16rem);
  gap: 0.9rem;
  margin: 0;
  padding: 0 1.25rem 0 0;
  list-style: none;
}
.scs__slide { scroll-snap-align: start; scroll-margin-left: 0; }
.scs__slide:target .scs__fig { border-color: var(--scs-accent); }
.scs__fig { height: 100%; margin: 0; overflow: hidden; background: var(--scs-surface); border: 2px solid var(--scs-line); border-radius: 14px; }
.scs__art { display: block; width: 100%; height: 7.5rem; }
.scs__cap { display: grid; gap: 0.15rem; padding: 0.8rem 0.95rem 1rem; }
.scs__count { color: var(--scs-accent); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.scs__name { font-size: 1.0625rem; }
.scs__desc { color: var(--scs-muted); font-size: 0.875rem; line-height: 1.45; }
.scs__jump { display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.35rem 1.25rem 0 0; }
.scs__dot { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; color: var(--scs-fg); text-decoration: none; border-radius: 10px; }
.scs__dot::before { content: ""; width: 0.7rem; height: 0.7rem; background: var(--scs-line); border: 2px solid var(--scs-muted); border-radius: 50%; transition: transform 0.15s ease; }
.scs__dot:hover::before { transform: scale(1.3); background: var(--scs-accent); border-color: var(--scs-accent); }
.scs__dot:focus-visible { outline: 3px solid var(--scs-ring); outline-offset: 0; }
.scs__dot-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (min-width: 40em) { .scs__slides { grid-auto-columns: 15rem; } }
@media (prefers-color-scheme: dark) {
  .scs {
    --scs-surface: #1a1e2e;
    --scs-fg: #edf0fa;
    --scs-muted: #b9bfd3;
    --scs-line: #3a4157;
    --scs-soft: #262b46;
    --scs-accent: #aeb1ff;
    --scs-on-accent: #14162b;
    --scs-ring: #c9cbff;
    box-shadow: none;
  }
  .scs__art { filter: brightness(0.82) saturate(0.9); }
}
@media (prefers-reduced-motion: reduce) {
  .scs__dot::before { transition: none; }
}

Accessibility notes

Written by the author of the snippet. Each note has a test step or a markup check that reads the page.

  • The scrolling row is a labelled region that takes keyboard focus, so arrow keys scroll it.
  • Jump links reach every slide and are not just dots: each has a text name.
  • The illustrations are decorative and hidden from screen readers.