Jump to content

Display different background images for mobile and desktop on home page only

Go to solution Solved by Ziggy,

Recommended Posts

Hi there,

 

I am looking for some help to display an alternative image on mobile on my home page in order to make the text on top of the image more legible.

I used the following piece of css from another thread, which worked however the image is displaying on all pages on mobile and I'd like for it to. appear on the home page only.


@media only screen and (max-width: 640px){
#page .page-section:nth-child(1) .section-background img {opacity:0 }
#page .page-section:nth-child(1)  .section-background {
background-image: url(https://static1.squarespace.com/static/635e701cba90e76df1723034/t/63f20b656fd184188261b044/1676807024721/diggers-cider-home-page-mobile-image.jpg);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
}

I'm sure just a simple line needs to be added here, but I've tried a few things and haven't got it yet. If anyone could help that would be great!

Note: I am actually using the same image, I have just cropped and exported a different version as need the darker area to be more visible on mobile. Tried. using the focal point selector tool but didn't work well enough.

Thanks a lot

 

 

Edited by ruralstudio
Link to comment
  • Replies 9
  • Views 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

Can you share your website URL? Thanks!

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment

Can you share the password too?

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment
  • Solution

You can try adding the homepage collection ID before the code you already have like this:

#collection-63b158dc4784523e8962ebc2 {
 @media only screen and (max-width:640px){
  #page .page-section:nth-child(1) .section-background img {
    opacity:0;
  }
  #page .page-section:nth-child(1) .section-background {
    background-image:url('https://static1.squarespace.com/static/635e701cba90e76df1723034/t/63f20b656fd184188261b044/1676807024721/diggers-cider-home-page-mobile-image.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }
 }
}

Let me know if that works!

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment
5 minutes ago, ruralstudio said:

Worked perfectly, thank you so much! 🙂

Nice one!

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

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.