Position Sticky

Position Sticky
0

#1

Hello,
I have heard of the position atribute in CSS but I don’t know how to use it,
do you have some advice?

Thanks


#2

If you are trying to use position relative/absolute to center things, my advice is not to. It is usually a lot more simpler to use flexbox for creating containers and centering.


#3

The article was very useful, but, I was trying to use position sticky.
Do you have advice for sticky position?
Thanks


#4

So something with postion sticky will scroll with the page as normal then switch to being fixed in the position you have specified it should be when it hits the edge of the viewport. So starts basically as normal position: static then turns into position:fixed. So look at how fixed works, apply rules like that. Support is actually ok for newest browsers.

Canonical use case is table heading rows that stick to the top as you scrolldown the table; very useful on mobile particularly. Site headers as well loke this site is a common one, though that’s often kinda an antipattern


#5

Ok,so much thanks guys!
Bye