Responsive hamburger menu behavior


#1

The website uses the always responsive hamburger menu. I would like the hamburger menu to display open by default in the home page only showing the menu links.

What would be the correct way to display the hamburger menu open including the hamburger icon animation only in the home page?


#2

What causes your hamburger menu to appear when you click on it? Is it a CSS class value that gets added to display it in its expanded state?


#3

The menu works as expected. I just want to display it open in the home page only. I am thinking to add the necessary css classes to the menu via javascript to the home page menu markup.


#4

Yep - that would work well. Another approach may be to use media queries and ensure the menu is in its expanded mode when there is available screen width. I prefer this approach over the JS one since your page has to run extra code that may cause a few moments where the menu’s size flashes from collapsed to visible. You can certainly mitigate that, but the media query approach seems much simpler.

:slight_smile:


#5

Good point. The tricky part is changing the responsive menu icon animation via css. The responsive menu can display open by adding the class ul#menu display block. However this does affect the responsive menu icon animation. Using css how would you change the state of the responsive menu icon from closed to open?


#6

Can you post a link to your example? There are many hamburger menu implementations, so I’d like to take a look at the one you are working on.