Jump to content

Change section background image on dark mode

Go to solution Solved by Beyondspace,

Recommended Posts

Hi all!

 

I am working on a dark mode version of my website. I am trying to change the first section background image of the landing page to another image when the viewer uses dark mode, but can't manage to make it work. Here is what I tried so far:

@media (prefers-color-scheme: dark) {
[data-section-id="5feca0a7dc82f97fd38e575d"] .section-background img {
    visibility: hidden;
}
/* set new image */
[data-section-id="5feca0a7dc82f97fd38e575d"] .section-background {
    background-image: url(https://static1.squarespace.com/static/5f0cd7575142de45f1d531a7/t/5feca8261d1415656f7995fb/1609345064730/WEBtransats_landingpage_night_123020.jpg);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
}
}
}

Any help is appreciated.

Thank you!

Edited by TOMweb
Link to comment
  • Solution
27 minutes ago, TOMweb said:

Site URL: https://endive-denim-89ds.squarespace.com/

pw: 1404-Hello

 

Hi all!

 

I am working on a dark mode version of my website. I am trying to change the first section background image of the landing page to another image when the viewer uses dark mode, but can't manage to make it work. Here is what I tried so far:


@media (prefers-color-scheme: dark) {
[data-section-id="5feca0a7dc82f97fd38e575d"] .section-background img {
    visibility: hidden;
}
/* set new image */
[data-section-id="5feca0a7dc82f97fd38e575d"] .section-background {
    background-image: url(https://static1.squarespace.com/static/5f0cd7575142de45f1d531a7/t/5feca8261d1415656f7995fb/1609345064730/WEBtransats_landingpage_night_123020.jpg);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
}
}
}

Any help is appreciated.

Thank you!

You got wrong id of the section, use this extension to find correct id

Chrome Web Store - Extensions (google.com)

@media (prefers-color-scheme: dark) {
      section[data-section-id="5f0cddf0784c68415c9814fb"] .section-background img {
        visibility: hidden;
      }
      /* set new image */
      section[data-section-id="5f0cddf0784c68415c9814fb"] .section-background {
        background-image: url(https://static1.squarespace.com/static/5f0cd7575142de45f1d531a7/t/5feca8261d1415656f7995fb/1609345064730/WEBtransats_landingpage_night_123020.jpg);
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center center;
      }
}

image.thumb.png.fed43e9a67819213174fcccd791cfa4a.png

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio plugin
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

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.