Jump to content

Changing logo colour ONLY in mobile menu overlay (7.1)

Go to solution Solved by tuanphan,

Recommended Posts

Site URL: https://fifty-fifth.com/

Hey! 

I've recently changed the logo colour on multiple pages on my site from navy to white - when viewing the site on mobile the pages with the white logo look a lot better when you click the burger and the menu overlay appears with my green background.

I want to make it so that when you press the burger icon on the pages with a navy logo, the logo changes to white when the green overlay appears. Is this possible with CSS? 

Thanks so much. 

Ned

Link to comment
  • 3 weeks later...
  • 2 weeks later...
  • Solution

Add this to Page Header

<style>
  /* hide current image */
.header-title-logo img {
    visibility: hidden;
}
  /* set new image on burger menu click */
  body.header--menu-open .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/5e8a138dedf9386b7757061f/t/5fc8e19e90a4f8549d839be0/1607000480214/%5BSITE%5D+%23FF_MASTER-LOGO_WHITE.png);
    background-size: cover;
    background-repeat: no-repeat;
}
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 1/2/2021 at 9:31 AM, tuanphan said:

Add this to Page Header


<style>
  /* hide current image */
.header-title-logo img {
    visibility: hidden;
}
  /* set new image on burger menu click */
  body.header--menu-open .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/5e8a138dedf9386b7757061f/t/5fc8e19e90a4f8549d839be0/1607000480214/%5BSITE%5D+%23FF_MASTER-LOGO_WHITE.png);
    background-size: cover;
    background-repeat: no-repeat;
}
</style>

 

Nailed it - thank you so much, you're a life saver! 

It didn't work at first but I made a slight addition to the 'hide current image' section and it worked perfectly.

New code below: 

<style>
/* hide current image */
body.header--menu-open .header-title-logo img {
    visibility: hidden;
}
  /* set new image on burger menu click */
  body.header--menu-open .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/5e8a138dedf9386b7757061f/t/5fc8e19e90a4f8549d839be0/1607000480214/%5BSITE%5D+%23FF_MASTER-LOGO_WHITE.png);
    background-size: cover;
    background-repeat: no-repeat;
}
</style>

 

Link to comment
  • 2 months later...

Hey @tuanphan this code doesn't work for me. Can you please help?

So I've got this code to display a different logo on the page in general...

<style> 
div.header-title-logo a {
content:url("https://static1.squarespace.com/static/5611841fe4b0f085582f2aa7/t/5ddc2f3f2e5a7339b69c08b2/1578936481584/?format=1500w") !important;     
max-width: 290px;
/* if logo needs to be centered */
margin-left: auto;
margin-right: auto;
}
</style>

But using your code in this post, it doesn't hide that logo when the menu overlay is open. It overlaps the both of them on top of each other.

<style>
  /* hide current image */
.header-title-logo img {
    visibility: hidden;
}
  /* set new image on burger menu click */
  body.header--menu-open .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/5e8a138dedf9386b7757061f/t/5fc8e19e90a4f8549d839be0/1607000480214/%5BSITE%5D+%23FF_MASTER-LOGO_WHITE.png);
    background-size: cover;
    background-repeat: no-repeat;
}
</style>

See screenshot...

Screenshot 2021-03-12 at 07.52.47.png

Link to comment
  • 2 weeks later...
On 3/12/2021 at 2:56 PM, Rav said:

Hey @tuanphan this code doesn't work for me. Can you please help?

So I've got this code to display a different logo on the page in general...


<style> 
div.header-title-logo a {
content:url("https://static1.squarespace.com/static/5611841fe4b0f085582f2aa7/t/5ddc2f3f2e5a7339b69c08b2/1578936481584/?format=1500w") !important;     
max-width: 290px;
/* if logo needs to be centered */
margin-left: auto;
margin-right: auto;
}
</style>

But using your code in this post, it doesn't hide that logo when the menu overlay is open. It overlaps the both of them on top of each other.


<style>
  /* hide current image */
.header-title-logo img {
    visibility: hidden;
}
  /* set new image on burger menu click */
  body.header--menu-open .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/5e8a138dedf9386b7757061f/t/5fc8e19e90a4f8549d839be0/1607000480214/%5BSITE%5D+%23FF_MASTER-LOGO_WHITE.png);
    background-size: cover;
    background-repeat: no-repeat;
}
</style>

See screenshot...

Screenshot 2021-03-12 at 07.52.47.png

Try new code

<style>
  /* hide current image */
body:not(.header--menu-open) .header-title-logo img {
    visibility: hidden;
}
  /* set new image on burger menu click */
  body:not(.header--menu-open) .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/5e8a138dedf9386b7757061f/t/5fc8e19e90a4f8549d839be0/1607000480214/%5BSITE%5D+%23FF_MASTER-LOGO_WHITE.png);
    background-size: cover;
    background-repeat: no-repeat;
}
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 11 months later...

Hi! I am having a similar problem on my site

https://newconductorsorch.squarespace.com/faq
PW: newconductors

This white logo disappears into the mobile overlay. This is actually a color logo, using SquareKicker to make it white. My "solution" is to use a completely different logo on the mobile overlay. [SquareKicker is not able to help me.]

I have injected this into my header, it is not showing up at all. 

<style>
  /* hide current image */
body:not(.header--menu-open) .header-title-logo img {
    visibility: hidden!important;
}
  /* set new image on burger menu click */
  body:not(.header--menu-open) .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/61e9e0a1c56e13742a1a45a4/t/622017f14c29f83be16f38e8/1646270449115/Submark+Black.png)!important;
    background-size: cover!important;
    background-repeat: no-repeat!important;
}
</style>

any ideas @tuanphan

 

Link to comment
On 3/3/2022 at 9:02 AM, AudeyTheConductor said:

Hi! I am having a similar problem on my site

https://newconductorsorch.squarespace.com/faq
PW: newconductors

This white logo disappears into the mobile overlay. This is actually a color logo, using SquareKicker to make it white. My "solution" is to use a completely different logo on the mobile overlay. [SquareKicker is not able to help me.]

I have injected this into my header, it is not showing up at all. 

<style>
  /* hide current image */
body:not(.header--menu-open) .header-title-logo img {
    visibility: hidden!important;
}
  /* set new image on burger menu click */
  body:not(.header--menu-open) .header-title-logo a {
    background-image: url(https://static1.squarespace.com/static/61e9e0a1c56e13742a1a45a4/t/622017f14c29f83be16f38e8/1646270449115/Submark+Black.png)!important;
    background-size: cover!important;
    background-repeat: no-repeat!important;
}
</style>

any ideas @tuanphan

 

Use this new code

<style>
  body.header--menu-open .header-title {
    filter: unset !important;
}
 body.header--menu-open header#header img {
    content: url(https://static1.squarespace.com/static/61e9e0a1c56e13742a1a45a4/t/622017f14c29f83be16f38e8/1646270449115/Submark+Black.png) !important;
}
</style>

image.thumb.png.a9b767f4490609b01a653b03224caba0.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 2 months later...
  • 11 months later...

I came across this problem recently (May 2023) and here is my solution - below is the code I inserted into the Page Header Code Injection in my case - incase it's helpful for anyone else searching for a solution to this problem 🙂

 
<style>
 /* Set a different logo for this page only - on desktop and mobile (if needed) */
div.header-title-logo a {
content:url("INSERT_IMG_LINK");     
max-width: 290px;
margin-left: auto;
margin-right: auto;
}
/* Hide Logo A when the mobile menu is open */
.header--menu-open .header-title-logo a {
  content: none;
}
/* Insert Logo B (as a background image) when the mobile menu is open */
.header--menu-open .header-title-logo a {
  background-image: url(INSERT_IMG_LINK);
  background-size: cover;
  background-repeat: no-repeat;
  }
</style>

 

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.