CSS scroll-snap Builder

Configure scroll-snap-type / scroll-snap-align.

Open tool

Overview

The CSS scroll-snap Builder configures scroll-snap-type on the container and scroll-snap-align on the children, plus the often-forgotten scroll-padding and scroll-margin helpers that anchor snap points away from sticky headers. Output is a complete pair of rules.

Useful when learning how to build a CSS scroll-snap carousel or how to make a horizontal scroller snap to each card. Reach for it for image galleries, story-style carousels, full-page scrollers, and any UI where scroll position should rest at meaningful waypoints.

How it works

The CSS Scroll Snap Module Level 1 defines scroll-snap-type on the scroll container — values like x mandatory, y proximity, both mandatory. mandatory forces the scroll to land on a snap point; proximity only snaps when the user releases close to one. Children declare scroll-snap-align: start | center | end to mark their snap edge.

scroll-padding shifts snap points inward (typically for a sticky nav above), and scroll-margin pads the inside of a snap target. The builder emits both when a non-zero offset is configured.

Examples

  • A horizontal card carousel → .scroller { scroll-snap-type: x mandatory; overflow-x: auto; } plus .card { scroll-snap-align: start; }.
  • Vertical full-page sections → html { scroll-snap-type: y mandatory; } and section { scroll-snap-align: start; min-height: 100vh; }.
  • Proximity snap so user can still scroll between → scroll-snap-type: x proximity.
  • Account for sticky header → scroll-padding-top: 60px; on the scroll container.

FAQ

Mandatory vs proximity?

mandatory always snaps and gives a more controlled feel — ideal for carousels. proximity only snaps when the user is close, preserving fluid scrolling — ideal for long reading pages with optional anchor stops.

Why does my snap point land hidden behind a sticky header?

The snap point is calculated against the scroll container's padding box. Add scroll-padding-top matching the header height and the target offsets correctly.

Can I scroll to a specific snap point in JavaScript?

Yes — element.scrollIntoView({ block: 'start' }) will land on the snap point because the browser snaps as part of the scroll.

Does scroll-snap work on the body?

Yes, but you must set scroll-snap-type on html (not body) for it to apply to page scrolling in most browsers.

Try CSS scroll-snap Builder

An unhandled error has occurred. Reload ×