Community forum for knowledge and support

Updated 8 months ago

Sticky Navbar Issue with Position Warning

At a glance

The community member has a navbar that they want to make sticky to the top of the page, but they are getting an info warning when they set the position to sticky. The comments suggest that the issue is likely due to the parent element not having relative positioning, so the navbar doesn't know where to "stick". Another community member provides a read-only link to the website, and suggests that the community member needs to define at what point from the top of the page they want the element to be sticky, such as 0 or 1rem/2rem. The community members discuss the issue and provide a solution, but there is no explicitly marked answer.

Useful resources

Hi There! I would like to have this navbar be sticky to the top but when I set its position to this, I get this info warning (see screenshot). Any idea why?

E
M
Q
5 comments

When you use sticky positioning, the element needs to be stuck ‘relative’ to another element. That would be the first parent element with relative positioning.

I guess your body element’s positioning isn’t set to relative, meaning the nav bar doesn’t know where to ‘stick’

Would you mind sending a read-only link?

you just need to define at what point from the top of the page do you want the element to be sticky. In this case I think you want 0. In some other cases, maybe you want it to be sticky after you've scrolled for 1rem or 2rem. It all depends.

Unfortunately you can't change the position of a body tag - its always static.

aha!!! You're the best! Thank you as always!

Add a reply
Sign up and join the conversation on Slack