Scroll Snap in CSS Instead of JavaScript



When we’re scrolling down a page, or through a gallery of images, snap-targets can help guide us from one section or image to the next. In the past, developers have used JavaScript to hijack scrolling, but now we can manage scroll alignment directly in CSS with only a few lines of code. The fallback even works well in old browsers! Miriam Suzanne shows you how.

script type="text/javascript" src="http://aos-creative.prf.hn/creative/camref:100l3Rd/creativeref:10l3694">

Image Gallery Demo: https://codepen.io/mirisuzanne/pen/bXRebo?editors=0100
Page Sections Demo: https://codepen.io/mirisuzanne/pen/vomNBg?editors=0100
More on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Scroll_Snap/Basic_concepts

#css #scrollsnap #miriamsuzanne

source

Reply


Build A Site Info