Should i use sticky or fixed when i want a navbar to move when i scroll

Tell us what’s happening:

Should i use position: sticky or fixed when i want a navbar to move when i scroll? I read that sticky doesnt work in Internet Explorer or Edge 15

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36.

Challenge: Build a Product Landing Page

Link to the challenge:

You definitely want to use fixed when you want to move the header at any point, because position sticky is like having 2 properties at one, absolute and fixed. Using fixed will also give you more control over your header position. I hope this helps you on your project.

1 Like

Thanks. But i find sticky easier to use. because for fixed i need to add maybe a margin and other codes for it not to overlap other content. while sticky i just need to add top:0;

But i am wonder if sticky should be completely avoided because some browsers dont support it and that its a bad practice to use sticky.

Nah… Internet explorer should be avoided because it doesn’t support. . . well, a lot of stuff… lol


1 Like