Hiding Liquid for mobile only won't work no matter what

Solved

Hiding Liquid for mobile only won't work no matter what

FrequencyWear
Tourist
4 0 1

- Whisper Theme

- Frequencywear.eu

 

I have created a custom Liquid to make my header Navigation a different Color than the Main Header. This though looks completely messed up on mobile, which is why i am trying to fix by making that specific liquid not apply for mobile.


the Liquid is assigned as a div via

 

<div class="headercolor"> [my custom liquid] </div>

 

I have tried the following:

 

Custom CSS + bottom of base.css:

 

@media screen and (max-width: 768px) {
.headercolor {
display: none;
}
}

 

Theme.liquid:

 

<style>
@media screen and (max-width: 768px) {
.headercolor {
display: none;
}
}
</<style>

 

 

this is on Desktop, all fine.

FrequencyWear_0-1734533444716.png

 

this is on mobile, very much messed up.

FrequencyWear_1-1734533472702.png

 

Accepted Solution (1)

ecoboostify
Shopify Partner
35 8 6

This is an accepted solution.

Adding custom Liquid code to style your header color can be effective, but it’s similar to making edits in your theme.liquid file or adjusting the base.css file. However, editing base.css is generally the better approach as it keeps your custom styles centralized and easier to manage.

Here’s how to proceed:
1. Remove existing custom code in <div class="headercolor"> and theme.liquid
2. Update the code in base.css

sticky-header.header-wrapper.gradient:after {
    content: "";
    background: #ab80da;
    display: block;
    width: 100%;
    height: 50px;
    margin-top: -50px;
}

sticky-header.header-wrapper.gradient {
    position: relative;
}

.header__active-menu-item,.header__menu-item,span.header__active-menu-item  {
    color: black;
}
@media screen and (max-width: 768px) {
    sticky-header.header-wrapper.gradient:after {
        display: none;
    }
}
It's truly fulfilling to help someone.
If this fixed your issue, Likes and Accept as Solution are highly appreciated.
EcoBoostify Shoppable Reel UGC - Easily Shoppable Videos+Reels, Inactive Tab Messages, Favicon Cart Counts, and more optimize store

View solution in original post

Replies 6 (6)

Made4uo-Ribe
Shopify Partner
9567 2278 2826

Hi @FrequencyWear 

PLease, share your store URL. Thanks!

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.
Create custom Shopify pages effortlessly with PageFly's drag-and-drop ⚙️.
FrequencyWear
Tourist
4 0 1

ecoboostify
Shopify Partner
35 8 6

This is an accepted solution.

Adding custom Liquid code to style your header color can be effective, but it’s similar to making edits in your theme.liquid file or adjusting the base.css file. However, editing base.css is generally the better approach as it keeps your custom styles centralized and easier to manage.

Here’s how to proceed:
1. Remove existing custom code in <div class="headercolor"> and theme.liquid
2. Update the code in base.css

sticky-header.header-wrapper.gradient:after {
    content: "";
    background: #ab80da;
    display: block;
    width: 100%;
    height: 50px;
    margin-top: -50px;
}

sticky-header.header-wrapper.gradient {
    position: relative;
}

.header__active-menu-item,.header__menu-item,span.header__active-menu-item  {
    color: black;
}
@media screen and (max-width: 768px) {
    sticky-header.header-wrapper.gradient:after {
        display: none;
    }
}
It's truly fulfilling to help someone.
If this fixed your issue, Likes and Accept as Solution are highly appreciated.
EcoBoostify Shoppable Reel UGC - Easily Shoppable Videos+Reels, Inactive Tab Messages, Favicon Cart Counts, and more optimize store
FrequencyWear
Tourist
4 0 1

It worked, thank you a lot!

pawankumar
Shopify Partner
644 95 119

Hi @FrequencyWear 
Please try replacing headercolor  custom liquid with this

<div class="headercolor">
<style>
@media (min-width: 769px){
sticky-header.header-wrapper.gradient:after {
    content: "";
    background: #ab80da;
    display: block;
    width: 100%;
    height: 50px;
    margin-top: -50px;
}

sticky-header.header-wrapper.gradient {
    position: relative;
}

.header__active-menu-item,.header__menu-item,span.header__active-menu-item  {
    color: black;
}
}

</style>
</div>

Thanks!

- Need a Shopify developer? Chat on WhatsApp +91-9467121281
- Coffee Tip: Buymeacoffee  | Email: thepkpawankumar@gmail.com
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Best regards,
Pawan
FrequencyWear
Tourist
4 0 1

This worked too, thank you very much!

Unfortunately i can only mark one reply as solution though.