Loading...
.carousel {
display: flex;
scroll-snap-type: x mandatory;
}.carousel {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
}
.carousel > * {
scroll-snap-align: start;
}Snapping needs a scroll container and snap positions on the children; without overflow and scroll-snap-align nothing snaps.
overflow set to 'auto' or 'scroll' on the snapping axis.'mandatory' always snaps to a snap point when scrolling stops. 'proximity' snaps only when the scroll ends close to one.
Set scroll-snap-stop: always on the items, so scrolling stops at each snap point.
Yes. Arrow keys and page keys scroll the container, and the browser snaps to the nearest snap point.