Skip to content
Advertisement

Bootstrap close responsive menu “on click”

On “PRODUCTS” click I slide up a white div (as seen in attached). When in responsive (mobile and tablet), I would like to automaticly close the responsive navbar and only show the white bar.

I tried:

JavaScript

also tried:

JavaScript

And it does work. However in desktop size, it is also called and does something funky to the menu where it shrinks for a second.

Any ideas?

enter image description here

Advertisement

Answer

I’ve got it to work with animation!

Menu in html:

JavaScript

Binding click event on all a elements in navigation to collapse menu (Bootstrap collapse plugin):

JavaScript

EDIT To make it more generic we can use following code snippet

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