Jump to content

Target PDP's with code to change navigation colour

Recommended Posts

https://coucoustudio.squarespace.com/

PW: CCS24

I used code to transform my header from transparent with white text to white background with black text on scroll. However, my PDP's have a white background and now the header doesn't show up on those pages because of this. 

 

Is there a way I can target the PDP's only to reverse this effect, so my header is constantly black? 

Thanks!

Link to comment

If your custom code is pure css you would need a not rule on .collection-type-products.view-item that wraps around your custom css. That way it will only apply to pages other than the product item pages. 

If your custom script has Javascript there would be a similar approach to only allow the script to trigger on non product pages. 

If you could post the custom code here it would be helpful.  

I'm Colin Irwin aka silvabokis.  I've been a Squarespace designer & developer since 2013. 
I remember when it was all wild prairies round these here parts. 🐃🤠
Advice I give on here is free, though I may sometimes post an affiliate link or promote something I've written.
That reminds me.. ..you might want to check out my
Squarespace template finder or have a look at my other Squarespace tips
Speaking of tips, 💲I've got a tip jar that you're welcome to throw a few quid into if you think I've helped you. 
If you're looking for a Squarespace developer 
Book a chat or Drop me a line - first meeting is always free  

 

Link to comment

Hey @colin.irwin

So the custom code is pretty long, as there's a few parts to it which create the effect at the moment

 

/******HOMEPAGE******/
header#header.shrink svg.icon {
    stroke: black;
    fill: black;
}
//-------------//
//***HEADER***//

header#header.shrink {
    background-color: white !important;
}
/* Change logo on scroll */ 
.shrink .header-title-logo img {
    visibility: hidden;
}
.shrink .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/6583ad4a5d6aab0922f2d42d/t/663d03d8b127c3081d3643f6/1715274712696/Artboard+1+copy+4.png);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
}

//--- nav link colour on scroll--//
header#header.shrink a {
    color: black;
    opacity: 1;
}
header#header.shrink img {
    filter: invert(1);
}
header#header.shrink use {
    fill: black !important;
    stroke: black !important;
}


//---- mobile nav----// (changes the logo and nav links colour from white the black)

body:not(.header--menu-open) header#header img {
content:url(https://static1.squarespace.com/static/6583ad4a5d6aab0922f2d42d/t/663d05a44b2a3437f0db91cd/1715275172328/Artboard+2.png) !important;}
  body.header--menu-open header#header img {
    content: url(https://static1.squarespace.com/static/6583ad4a5d6aab0922f2d42d/t/663d03d8b127c3081d3643f6/1715274712696/Artboard+1+copy+4.png);}
 

Thank you for the help so far! 

Link to comment

Try this 


body:not(.collection-type-products.view-item) {
    /******HOMEPAGE******/
header#header.shrink svg.icon {
    stroke: black;
    fill: black;
}
//-------------//
//***HEADER***//

header#header.shrink {
    background-color: white !important;
}
/* Change logo on scroll */ 
.shrink .header-title-logo img {
    visibility: hidden;
}
.shrink .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/6583ad4a5d6aab0922f2d42d/t/663d03d8b127c3081d3643f6/1715274712696/Artboard+1+copy+4.png);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
}

//--- nav link colour on scroll--//
header#header.shrink a {
    color: black;
    opacity: 1;
}
header#header.shrink img {
    filter: invert(1);
}
header#header.shrink use {
    fill: black !important;
    stroke: black !important;
}


}
/******HOMEPAGE******/
header#header.shrink svg.icon {
    stroke: black;
    fill: black;
}
//-------------//
//***HEADER***//

header#header.shrink {
    background-color: white !important;
}
/* Change logo on scroll */ 
.shrink .header-title-logo img {
    visibility: hidden;
}
.shrink .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/6583ad4a5d6aab0922f2d42d/t/663d03d8b127c3081d3643f6/1715274712696/Artboard+1+copy+4.png);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
}

//--- nav link colour on scroll--//
header#header.shrink a {
    color: black;
    opacity: 1;
}
header#header.shrink img {
    filter: invert(1);
}
header#header.shrink use {
    fill: black !important;
    stroke: black !important;
}


//---- mobile nav----// (changes the logo and nav links colour from white the black)

body:not(.header--menu-open) header#header img {
content:url(https://static1.squarespace.com/static/6583ad4a5d6aab0922f2d42d/t/663d05a44b2a3437f0db91cd/1715275172328/Artboard+2.png) !important;}
  body.header--menu-open header#header img {
    content: url(https://static1.squarespace.com/static/6583ad4a5d6aab0922f2d42d/t/663d03d8b127c3081d3643f6/1715274712696/Artboard+1+copy+4.png);}

 

I'm Colin Irwin aka silvabokis.  I've been a Squarespace designer & developer since 2013. 
I remember when it was all wild prairies round these here parts. 🐃🤠
Advice I give on here is free, though I may sometimes post an affiliate link or promote something I've written.
That reminds me.. ..you might want to check out my
Squarespace template finder or have a look at my other Squarespace tips
Speaking of tips, 💲I've got a tip jar that you're welcome to throw a few quid into if you think I've helped you. 
If you're looking for a Squarespace developer 
Book a chat or Drop me a line - first meeting is always free  

 

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.