Skip to content
Advertisement

Nav Element Disappears When Parents Element’s Position Changed to Sticky

I have a navbar div that has a title and a nav component. When the window gets small enough I collapse the nav element so have a burger to show and hide the nav element. Without changing the position attribute of the parent navbar div it works fine, however when I make the parent navbar div sticky I can no longer see the navbar move over onto the screen. I toggle the navbarHidden and navbarVisible class on the child nav element when the burger is clicked.

JavaScript

The nav element still shows up when you inspect the page though.

enter image description here

Advertisement

Answer

I figured it out, all you had to do was change the position on the nav element to fixed instead of absolute.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement