Change menu nav colour on some pages

Solved

Change menu nav colour on some pages

unadiamond
Excursionist
29 0 5

Hi!

 

I'd like to change the menu nav colour on some pages to beige and others to green. I've tried this snipped in my theme.liquid file but no dice. My default menu nav colour in my theme editor is beige, but something is still making the ones I want to be beige, green. I've tried the code snippets below with no luck:

 

<style>
{% if template.name == 'page.about' or
template.name == 'page.privacy' or
template.name == 'page.returns-refunds' or
template.name == 'page.shipping' or
template.name == 'page.legal' or
template.name == 'page.faq' or
template.name == 'page.default' or
template.name == 'page.contact' %}
.navtext {
color: #004335 !important; /* Green color for specified pages */
}
{% else %}
.navtext {
color: #f5f5dc !important; /* Beige color for all other pages */
}
{% endif %}
</style>

 

AND:

 

<style>
{% if template.name == 'index' or
template.name == 'page.learning-about-lab-grown' or
template.name == 'page.all-about-diamonds' or
template.name == 'page.our-process' or
template.name == 'page.lookbook' or
template.name == 'page.how-to-find-your-ring-size' %}
.navtext {
color: #f5f5dc !important; /* Beige color for specified pages */
}
{% endif %}
</style>

 

My website is unadiamond.com

Accepted Solution (1)

namphan
Shopify Partner
2690 349 398

This is an accepted solution.

Hi @unadiamond,

Please change code:

template.name

=>

template

For example:

<style>
{% if template == 'page.about' or
template == 'page.privacy' or
template == 'page.returns-refunds' or
template == 'page.shipping' or
template == 'page.legal' or
template == 'page.faq' or
template == 'page.default' or
template == 'page.contact' %}
.navtext {
color: #004335 !important; /* Green color for specified pages */
}
{% else %}
.navtext {
color: #f5f5dc !important; /* Beige color for all other pages */
}
{% endif %}
</style>

 

Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com

View solution in original post

Replies 9 (9)

Guleria
Shopify Partner
4146 809 1164

Hello @unadiamond ,

 

Important is already used in the cs that's why your css is not working.

You need to use parent element with the class to override it.

like

 

.navlink .navtext{

  // You css will be here 
color: #f5f5dc !important;

}

 

Please give it a try and let me know.

 

If problem solved don't forget to Like it and Mark it as Solution!
And if you need help with customization/code part you can contact me for services

You can find the email in the signature below.

 

Thanks

- Custom themes, UI/UX design, ongoing maintenance & support.
- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder

PageFly-Richard
Shopify Partner
5011 1120 1803

Hi @unadiamond 

 

This is Richard from PageFly - Shopify Page Builder App

 

If your current code is targeting the Template-Name and apply the CSS based on Condition, i suggest you can do another is handle of page. 

So for example your page is = /pages/learning-about-lab-grown' => so the code will be 

{% if handle contains 'learning-about-lab-grown' %}

 

This will target it by URL and you will have more easier way to control it

 

Hope this can help you solve the issue 

 

Best regards,

Richard | PageFly 

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 


All features are available from Free plan. Live Chat Support is available 24/7.

namphan
Shopify Partner
2690 349 398

This is an accepted solution.

Hi @unadiamond,

Please change code:

template.name

=>

template

For example:

<style>
{% if template == 'page.about' or
template == 'page.privacy' or
template == 'page.returns-refunds' or
template == 'page.shipping' or
template == 'page.legal' or
template == 'page.faq' or
template == 'page.default' or
template == 'page.contact' %}
.navtext {
color: #004335 !important; /* Green color for specified pages */
}
{% else %}
.navtext {
color: #f5f5dc !important; /* Beige color for all other pages */
}
{% endif %}
</style>

 

Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com
unadiamond
Excursionist
29 0 5

you're the best, thank you!!!

namphan
Shopify Partner
2690 349 398

Hi @unadiamond,

You're welcome and happy to help

Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com
unadiamond
Excursionist
29 0 5

sorry quick follow up - how do i make the blog and product pages green too? i've followed the logic of your code and applied them to page.product + page.blog but they remain beige

unadiamond
Excursionist
29 0 5

sorry quick follow up - how do i make the blog and product pages green too? i've followed the logic of your code and applied them to page.product + page.blog but they remain beige

namphan
Shopify Partner
2690 349 398

Hi @unadiamond,

Please add code:

<style>
{% if template == 'page.about' or
template == 'page.privacy' or
template == 'page.returns-refunds' or
template == 'page.shipping' or
template == 'page.legal' or
template == 'page.faq' or
template == 'page.default' or
template == 'page.contact' or
template == 'product' or
template == 'blog' %}
.navtext {
color: #004335 !important; /* Green color for specified pages */
}
{% else %}
.navtext {
color: #f5f5dc !important; /* Beige color for all other pages */
}
{% endif %}
</style>
Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com

Dan-From-Ryviu
Shopify Partner
11683 2289 2472

Hi @unadiamond 

You can try to use code example like this below and check 

{% if template == 'index' or
       page.handle == 'about' or ... }%
<style>
</style>
{% else %}
<style>
</style>
{% endif %}

- Helpful? Like & Accept solution! - Support me? Buy me a coffee
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...
Sign up now.