CSS 3 · Positioning, effects and animation

Snap to items while scrolling

Make a horizontal carousel stop at each item.

.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}
.carousel > * {
  scroll-snap-align: start;
}

Official CSS 3 documentation

More positioning, effects and animation commands

All positioning, effects and animation commands · CSS 3 cheatsheet

Was this page helpful?