{"id":283331,"date":"2019-03-07T08:22:17","date_gmt":"2019-03-07T15:22:17","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=283331"},"modified":"2019-05-29T07:33:40","modified_gmt":"2019-05-29T14:33:40","slug":"scroll-snap-stop","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/s\/scroll-snap-stop\/","title":{"rendered":"scroll-snap-stop"},"content":{"rendered":"
See the Pen scroll-snap-stop example This browser support data is from Caniuse<\/a>, which has more detail. A number indicates that browser supports the feature at that version and up.<\/p><\/div>scroll-snap-stop<\/code> is part of the CSS Scroll Snap Module. Scroll snapping refers to “locking” the position of the viewport to specific elements on the page as the window (or a scrollable container) is scrolled. Think of a scroll-snapping container like putting a magnet on top of an element that sticks to the top of the viewport and forces the page to stop scrolling right there.<\/p>\n
scroll-snap-stop<\/code> is an optional property for a scroll-snapping element within a scroll-snapping container. For more information on scroll-snapping containers see the
scroll-snap-type<\/code> almanac entry<\/a>.<\/p>\n
scroll-snap-stop<\/code> allows you to force<\/em> the scroll-snapping container to snap to a particular element. Suppose you were scrolling within a scroll-snapping container, and you gave it a giant spin-of-the-mousewheel. Normally, the browser would let the velocity of your scrolling fly past snap points until it settled on a snap point close to where the scrolling would normally end. By setting
scroll-snap-stop<\/code> you can tell the browser that it must<\/em> stop on a particular element before allowing the user past it.<\/p>\n
\/* Assuming this element is a child of a container with `scroll-snap-type` set *\/\r\n.element {\r\n scroll-snap-stop: always;\r\n}<\/code><\/pre>\n
Syntax<\/h3>\n
scroll-snap-stop: normal | always;<\/code><\/pre>\n
Values<\/h3>\n
scroll-snap-stop<\/code> accepts the following values:<\/p>\n
\n
normal<\/code> is the default value and allows an element to be scrolled past without snapping<\/li>\n
always<\/code> will force the browser to snap to this element, even if the scroll would normally go past this element<\/li>\n<\/ul>\n
Example<\/h3>\n
\n<\/a> by CSS-Tricks (@css-tricks<\/a>) on CodePen<\/a>.<\/p>\nBrowser Support<\/h3>\n
Desktop<\/h4>