Skip to content

gforti/scroll-snap

Repository files navigation

Scroll Snap CSS

CSS Scroll Snap demo

The scroll-snap-type CSS property sets how strictly snap points are enforced on the scroll container in case there is one.

Format

scroll-snap-type: none | [ x | y | block | inline | both ] [ mandatory | proximity ]

Sample CSS

/* Optional mandatory | proximity*/
scroll-snap-type: x mandatory;
scroll-snap-type: y proximity;
scroll-snap-type: both mandatory;

The inner container must also have the following style

scroll-snap-align: center;

Final

.container {
  scroll-snap-type: y mandatory;
}

.child {
  scroll-snap-align: start;
}

Resoruces