We're a place where coders share, stay up-to-date and grow their careers.
Nice post! Is there any reason that you couldn't do this with the more widely-supported position: fixed?
position: fixed
"Fixed" is always fixed to the window coordinates, while "sticky" is displaying similar behavior like elements made with javascript. Solving this UI problem with CSS is always a better solution when it comes to UI performance.
Here is an example I found online: codepen.io/nyctophiliac/pen/xpmpyp
Worldwide adoption is 86%, so we may start to use it.
caniuse.com/#search=position%3Asticky
As always, only retarded Microsoft browsers are problematic.
I understand the difference, however in the example the sidebar starts at the top anyway so there is no difference.
Make window smaller and scroll up and down, so you will notice where is the difference.
Nice post! Is there any reason that you couldn't do this with the more widely-supported
position: fixed
?"Fixed" is always fixed to the window coordinates, while "sticky" is displaying similar behavior like elements made with javascript. Solving this UI problem with CSS is always a better solution when it comes to UI performance.
Here is an example I found online: codepen.io/nyctophiliac/pen/xpmpyp
Worldwide adoption is 86%, so we may start to use it.
caniuse.com/#search=position%3Asticky
As always, only retarded Microsoft browsers are problematic.
I understand the difference, however in the example the sidebar starts at the top anyway so there is no difference.
Make window smaller and scroll up and down, so you will notice where is the difference.