🎠 CSS

CSS Scroll Snap — Build a Carousel With Zero JavaScript

📅 Jul 3, 2026 ⏱ 3 min read

Carousel libraries: 40KB of JS. Scroll snap: 4 lines of CSS with native momentum, touch support and accessibility.

The whole carousel

.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;   /* snap on the x axis, always */
  gap: 16px;
  scrollbar-width: none;           /* hide the bar */
}
.slide {
  flex: 0 0 85%;                   /* peek of the next slide */
  scroll-snap-align: center;
}

Full-page snap sections

html { scroll-snap-type: y proximity; }   /* proximity = gentler than mandatory */
section { min-height: 100vh; scroll-snap-align: start; }

Polish

Demo it in the Playground in two minutes.

← All Articles