DevTools Logo

CSS Scroll Snap Builder

CSS Scroll Snap Builder

Configure scroll-snap-type, alignment, stop behavior and padding on a live carousel, then copy the CSS.

Runs in your browser
Try an example

Carousel demo

6 slides · x mandatory
Snap 1 of 6
Slide 1
Slide 2
Slide 3
Slide 4
Slide 5
Slide 6

6 snap positions at 0px, 192px, 384px, 576px, 740px, 740px.

Apply to all slides

Slide 1
Slide 2
Slide 3
Slide 4
Slide 5
Slide 6

Generated CSS

6 snap positions · LTR
.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
}

.slide:nth-child(1) {
  scroll-snap-align: start;
}
.slide:nth-child(2) {
  scroll-snap-align: start;
}
.slide:nth-child(3) {
  scroll-snap-align: start;
}
.slide:nth-child(4) {
  scroll-snap-align: start;
}
.slide:nth-child(5) {
  scroll-snap-align: start;
}
.slide:nth-child(6) {
  scroll-snap-align: start;
}

scroll-padding belongs on the container and shifts the snapport; scroll-margin belongs on each slide and shifts the snap area. Markers are computed from the same offsets the browser uses.

Examples

Padded gallery

Input
x mandatory, scroll-padding-left 40px, align start
Output
Markers move 40px left of each slide's leading edge

Container padding shifts the snapport; it does not move the slide boxes.

Story reel

Input
scroll-snap-stop: always on all six slides
Output
A fast flick advances exactly one slide

Mandatory snapping alone permits skipping; always-stop prevents it.

About this tool

CSS Scroll Snap Builder turns a carousel into something you can feel before you ship it. Choose an axis and strictness, set scroll-padding on the container, tune each slide's scroll-snap-align, scroll-snap-stop and scroll-margin, and a real scrolling demo updates with tick markers at the computed snap positions.

The property split is the part most tutorials gloss over: scroll-padding changes the snapport on the container, while scroll-margin changes each slide's snap area. Because both are connected to the same marker math, confusion between them becomes visible immediately. A right-to-left toggle demonstrates how start and end flip, and presets cover image carousels, padded galleries and story reels that must stop on every slide.

The CSS pane emits only non-default declarations, with a container block and a block per configured slide. Prev and next buttons scroll to the same computed targets a script would use. The builder is CSS-only: no autoplay, no JavaScript carousel code and no polyfill — snapping runs in the browser's native scroll engine.

What this tool does not do

  • The markers are computed from configured geometry and do not read arbitrary nested layouts.
  • Nested scrollers and shareable URLs are out of scope; the demo uses a single scroller.
  • Browser support for scroll-snap-stop varies on touch platforms; the tool emits standard CSS without a polyfill.
  • Vertical snapping is modeled with the same geometry, but the demo carousel is horizontal.

How to use this tool

  1. Load a preset

    Start with an image carousel, a padded gallery or a story reel, or configure everything from scratch.

  2. Set container rules

    Pick an axis and mandatory/proximity strictness, set scroll-padding per side, and decide whether scrolling should be smooth.

  3. Tune the slides

    Use the slide rail to set align and stop per slide, or apply an alignment to all slides at once. Adjust width, count and gap in the demo.

  4. Scroll and copy

    Drag or wheel the carousel to feel the snapping, read the markers, then copy the generated CSS.

Use cases

Carousels

Prototype a swipeable image rail with predictable snap points.

Design systems

Standardize snap type, padding and stop rules across product surfaces.

Learning modern CSS

Compare proximity and mandatory behavior on the same content.

Container versus child properties

PropertyWhere it goes
scroll-snap-typeContainer
scroll-padding-*Container
scroll-snap-alignChild
scroll-snap-stopChild
scroll-margin-*Child
direction: rtlContainer

Slides with scroll-snap-align: none are skipped when computing markers and CSS.

Common mistakes

Mistake:Putting scroll-padding on the slides.

Fix:Padding goes on the scrolling container; use scroll-margin on slides instead.

Mistake:Expecting mandatory snapping to stop a fast flick on every slide.

Fix:Add scroll-snap-stop: always where skipping must be prevented.

Mistake:Assuming start always means the left edge.

Fix:In RTL the scroll origin is on the right; toggle the direction to see the mirror.

Frequently asked questions

Mandatory vs proximity — which should I use?

Mandatory always lands on a snap point, which is right for carousels and galleries. Proximity only snaps when the scroll ends close to a snap point, so it suits long content where free scrolling matters.

What is the difference between scroll-padding and scroll-margin?

scroll-padding is set on the scrolling container and insets the snapport; scroll-margin is set on each child and extends its snap area. Both shift snap positions, but they belong to different elements.

How does snapping behave in RTL?

The scroll origin moves to the right edge, so start/end alignment and scroll-padding-left/right mirror. The builder's RTL toggle recomputes markers with that mirrored origin.

Does scroll-snap-stop: always work on touch?

It is supported in modern browsers, but implementation details vary. It is a hint that a scroll must not skip the snap area; always test the target devices for your carousel.

Is there a polyfill for CSS scroll snapping?

Browser support is broad today. Older engines may need a JavaScript carousel fallback, but this builder emits standard CSS only and does not add a polyfill.

References & standards