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
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:
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:
header.liquid file in the sections directorybase.css to include width: 100%, display: flex, and justify-content: centerThis 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.
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:
Go to Shopify Admin Panel
Select Online Store
In Online Store click the “customize button”
In Customize page, select the “header” section.
In header section there is a field to add custom css.
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
Go to Shopify Admin Panel
Select Online Store
. In Online Store click the “…” and choose “edit code” from the menu.
/* 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;
}
@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;
}
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
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:
Go to Shopify Admin Panel
Select Online Store.
In Online Store click the “…” and choose “edit code” from the menu.
In edit code, Open “header.liquid” in sections directory
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
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