The brand new CSS Scroll Snap Points spec guarantees to aid, making it possible for this sort of behavior utilizing not many lines of CSS.
This spec has changed over time as happens with very new web tech. There clearly was вЂњoldвЂќ and вЂњnewвЂќ properties and values. It is guaranteeing though, as help has raised quickly. IвЂ™ll teach you the way to have the support that is widest in this in-between phase.
The demo below has horizontal scrolling. ItвЂ™s responsive: each вЂњpanelвЂќ could be the width and height regarding the viewport (by way of vh and vw devices).
It works on the polyfill, however in purchase to make use of it (and help continues to be low enough that i would recommend you will do), you need to offer the вЂњoldвЂќ values, and that’s why IвЂ™ll address them, too.
- So you can mostly clearly see how the native behavior looks and feels if youвЂ™re looking in Firefox: it has the best current support.
- You notice in those browsers can be attributed to the polyfill entirely if youвЂ™re looking Chrome or Opera: donвЂ™t have any support, so any behavior.
- If youвЂ™re looking in Edge or IE: it probably wonвЂ™t work on all. These browsers have actually partial help, but evidently maybe maybe not sufficient to get this work.
- It(tested on an iPhone 6), but IвЂ™ve seen the easing behavior act pretty weird if youвЂ™re looking on a mobile device: iOS 9 supports. No Chrome/Android help, however the polyfill kicks in and handles it pretty much (tested on a android os Nexus 6).
Note IвЂ™m Autoprefixer that is using in Pen to immediately give me personally all the necessary vendor-prefixed properties.
HereвЂ™s the code utilized in order to make the miracle:
Pretty slim! LetвЂ™s break up these properties 1 by 1.