The scroll-snap-* Properties.

The following examples are overflow-scrolling divs. In the second, third and fourth examples, the blue cross represents the location of each container’s scroll snap destination.

This first container does not have any scroll snapping behavior.

1

2

3

4

This second container shows what basic scroll snapping can do for us.

1

2

3

4

The CSS for the above container is:

scroll-snap-type: x mandatory;

The CSS for each of the container’s children is:

scroll-snap-align: start;

This next container snaps to elements of different sizes when scrolling.

1

2

3

4

5

6

7

The CSS for the above container is:

scroll-snap-type: x mandatory;

The CSS for each of the container’s children is:

scroll-snap-align: start;

Here, we snap elements of different sizes to the center of the container.

1

2

3

4

5

6

7

The CSS for the above container is:

scroll-snap-type: x mandatory;

The CSS for each of the container’s children is:

scroll-snap-align: center;

This container shows centered scroll snapping in a 2D grid.




The CSS for the above container is:

scroll-snap-type: both mandatory;

The CSS for each of the container’s children is:

scroll-snap-align: center;

This example takes the 2D scroll snapping grid above and rotates it by 30 degrees.




The CSS for the above container is:

scroll-snap-type: both mandatory;
transform: rotate(30deg);

The CSS for each of the container’s children is:

scroll-snap-align: center;

Images from NASA’s image of the day gallery.