Mrs. Yanti’s sliding display: set scroll-snap-type on the rail or the crates, snap-align and scroll-padding, push the rail, and the browser stops the scroll…
Carousels and galleries are everywhere, and they used to need a JS library. With scroll-snap the browser handles the momentum, the keyboard and the scroll accessibility; you only say where to stop.
scroll-snap-type on the container, scroll-snap-align on the children
scroll-snap-type and scroll-snap-align are set but the cards still do not snap Usually swapped. scroll-snap-type goes on the scrolling CONTAINER (the one with overflow), scroll-snap-align on each CHILD. Check the container’s computed scroll-snap-type: if it is none, it is written in the wrong place.mandatory does: always to a snap point. For content read slowly (articles, long feeds), use proximity, which only pulls when the stop is close.scroll-padding-top (the header’s height) on the container. The snap line drops below the header, so cards stop in the visible part.+160px with mandatory scrollBy asks for 160px, but the browser stops at the next snap point. Its notch on the rail lights up.proximity, stop far from a snap point Push to between two crates. Far from a snap point, the browser leaves it there.scroll-snap-align start, center and end The snap line moves: the left edge, the middle, the right edge of the glass. The notches on the rail move with it.scroll-padding-top to 48px A crate that stops now sits below the sticky heading, not behind it.