That’s actually two questions, but I think they are well related.
I have a bootstrap 5 navbar. In small devices, when it’s collapsed, once I select an item, it remains open. I know it should load collapsed on reload, but I’m buliding a SPA page, and the navbar is part of the main layout.
Also, when it opens, does not overlap the background but drag the content downwards.
How could I change these behaviors?
First of all, thank you for your help.
But I’m sure someone else have done it before. Since it’s the most common type of navbar outthere. A sticky top navbar wich closes onclick and overlaps the content.
Actually, it only pushes when inmediately down there’s a column with image background, and overlaps the rest of the content.
Regarding the auto close option, there’s another old post, but looks that is’t working over bootstrap 5 navbar
Thanks for the link.
As i explained in my previous posts - change the navbar position to fixed top so it doesn’t push the content below. When using sticky top position and not scrolled down the page the element is acting like a relatively positioned, which pushes your content down.
I really apreciate your help Teodor.
But my question was if t’s posible to do it with a sticky menu, if someone knew a trick.
Also, for closing the dropdown after selecting an item. You said to me to do it with custom JS, but I can’t generate JS (tha’s why I like Wappler). I understand that maybe goes beyond the Wappler oficial support . But again, maybe someone else as comunity member, is willing to give me a hand.
But that is how the sticky position is supposed to work. Posted a link explaining that. Position sticky toggles the position between relative and fixed , depending on the scroll position. When you have not scrolled and when the element has not reached the top of the screen, it has a relative position! This means it will push the content down.
Scrolling past the page top, the element has a fixed position. Then it does not push the content ...
If you don't want this behavior (which is how CSS works, not a Wappler thing) change the position of the navbar to fixed top, so that it uses fixed position always.
Wappler relies on what the Bootstrap 5 framework offers. If you need any customizations of the core functionality, Wappler cannot offer a magic wand that does this.
Here's a code you can put at the bottom of the page, before the closing </body> tag, which should do the job: