Jump to content

Header bkg color with hamburger menu on desktop

Recommended Posts

Hey friends!

I am having a weird issue with custom CSS. I've used the following CSS code to force the mobile hamburger menu on desktop as well.

/* 768 for tablet - desktop - 992 for desktop */
@media screen and (min-width:768px) {
 /* hide navigation */
    .header-nav {
    display: none;
}
/* Hide header button */
.header-actions {
    display: none;
}
/* show burger */
.header-burger {
  display: flex;
}
/* Show overlay mobile menu */
.header--menu-open .header-menu {
  opacity: 1;
  visibility: visible;
  width: 40%;
  margin-left: 60%;}
}

Everything is working great, except when the menu is open the header changes to an overlay header rather than the solid background color. I attempted to add the background color with an important property with no luck. Has anyone done this and found a solution? 

Screenshot 2023-08-17 at 9.54.25 AM.png

Screenshot 2023-08-17 at 9.54.33 AM.png

Edited by ameliaprotiva
Slight change in code
Link to comment

@ameliaprotiva Here's the updated code:

/* 768 for tablet - desktop - 992 for desktop */
@media screen and (min-width:768px) {
 /* hide navigation */
    .header-nav {
    display: none;
}
/* Hide header button */
.header-actions {
    display: none;
}
/* show burger */
.header-burger {
  display: flex;
}
/* Show overlay mobile menu */
.header--menu-open .header-menu {
  opacity: 1;
  visibility: visible;
  width: 100% !important;
  margin-left: 0% !important;}
}

Let me know if it works. Thanks! 

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.