How do I change the menu background to white colour and not the entire header?

Topic summary

A user wants to apply a white background specifically to the menu section of their Shopify store header, rather than the entire header area.

Initial Solution Provided:
Two methods were offered to add white background to the menu:

  • Method 1: Add custom CSS through the Shopify theme customizer’s header section
  • Method 2: Directly edit the base.css file (requires technical knowledge)

Both methods use CSS targeting .header__inline-menu with background-color: #ffffff.

Follow-up Issue:
The user successfully implemented the code but encountered a new problem: the white background only covers half the area and doesn’t stretch to the edges.

Advanced Solution:
A more complex fix was provided requiring:

  • Editing the header.liquid file in the sections directory
  • Moving specific liquid code blocks (around line 191) to restructure the header layout
  • Updating CSS in base.css to include width: 100%, display: flex, and justify-content: center

This solution requires development knowledge of Shopify Liquid and CSS. The discussion remains open as implementation of the edge-to-edge solution hasn’t been confirmed.

Summarized with AI on November 7. AI used: claude-sonnet-4-5-20250929.

Hi,

I have added a background colour to the whole site, but I want to keep a white background only for the area of the menu section and not the entire header.
THEME- SENSE

Kindly suggest to me what can I do

@Lishagautam - can you please share this page link?

Hi @Lishagautam ,

There are two ways to achieve your desired requirement:

Method 1:

  1. Go to Shopify Admin Panel

  2. Select Online Store

  3. In Online Store click the “customize button”

  4. In Customize page, select the “header” section.

  5. In header section there is a field to add custom css.

  6. Add below given CSS style code in the field and save.

.header__inline-menu {
background-color: #ffffff;
width: 100%;
display: flex;
justify-content: center;
}

Method 2:

In this method, you might require some knowledge about the Shopify themes and CSS

  1. Go to Shopify Admin Panel

  2. Select Online Store

. In Online Store click the “…” and choose “edit code” from the menu.

  1. In base.css, you’ll find the following code in line - 2731 (can vary depending on the version of theme and customization done on it)
/* Header menu */
.header__inline-menu {
margin-left: -1.2rem;
grid-area: navigation;
display: none;
}

Change the above code as following:

/* Header menu */
.header__inline-menu {
margin-left: -1.2rem;
grid-area: navigation;
display: none;
background-color: #fffff;
}
  1. Just below the updated code, you’ll find the following code: (line - 2743/2744)
@media screen and (min-width: 990px) {
.header__inline-menu {
display: block;
}

.header--top-center .header__inline-menu {
justify-self: center;
}

Update these code into:

@media screen and (min-width: 990px) {
.header__inline-menu {
display: flex;
width: 100%;

}

.header--top-center .header__inline-menu {
justify-content: center;
}
  1. Save the file and reload your website, the style will be applied

Note: instead of #ffffff, you can give any color code of your choice.

If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!

Regards,

Sweans

1 Like

Hi,

Thank you so much. The above code worked but I want the white background to stretch all the way to the edges. Right now it covers only half the area. Kindly advice.

To stretch the white background all the way to the edges you need to edit the code in theme files and update css in base.css file. To make these edits you might need development knowledge in Shopify liquid and css.
You can follow the below mentioned steps to achieve your requirement:

  1. Go to Shopify Admin Panel

  2. Select Online Store.

  3. In Online Store click the “…” and choose “edit code” from the menu.

  4. In edit code, Open “header.liquid” in sections directory

  5. Make the following change in the header.liquid file:

Find the following code: (line 191)

{%- liquid
      if section.settings.menu != blank
        if section.settings.menu_type_desktop == 'dropdown'
          render 'header-dropdown-menu'
        elsif section.settings.menu_type_desktop != 'drawer'
          render 'header-mega-menu'
        endif
      endif
    %}

Cut the above code from there and paste it in the next line after the following code: (line 308 - add a new line and paste the code)

Eg:-


{%- liquid
      if section.settings.menu != blank
        if section.settings.menu_type_desktop == 'dropdown'
          render 'header-dropdown-menu'
        elsif section.settings.menu_type_desktop != 'drawer'
          render 'header-mega-menu'
        endif
      endif
    %}

After making the changes save the file

  1. Open the base.css file and make the following changes in there:

Replace the previously updated code with the code given below: (line - 2743/2744):

@media screen and (min-width: 990px) {
  .header__inline-menu {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-left: 0;
  }

After making the changes save the file and reload your website

If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!

Regards,

Sweans

2 Likes