Jump to content

Different image background on mobile for a hidden page (home)

Go to solution Solved by FredP,

Recommended Posts

Hello,

I am struggling to change the background image of my home page on mobile. 
Here is the URL of my website:
https://www.fredetcam.com

Here is the code I injected in the custom CSS section:
 

 @media only screen and (max-width: 640px){
[data-section-id="63987d07c71b4732240d4058"].section-background img { opacity:0!important }}


 @media only screen and (max-width: 640px){
[data-section-id="63987d07c71b4732240d4058"] .section-background {
background-image: url(https://static1.squarespace.com/static/63987c03bf68e244c3d2b2ce/t/63bc4a45670e3049b76acef1/1673284168258/Invitation-Vertical.jpg);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
}

Here is the image I would like to use on mobile:

 Invitation-Vertical.jpg

I saw different posts about this topic but didn't find a solution...
If someone could help me.

Thanks in advance,
Fred

Link to comment

Hey @tuanphan,

I would like to use a different image, and only for the main page. (the other pages don't matter).

I added the code and imported the image in design > custom CSS > manage custom file. The link works well, but the code doesn't! 😉

Thanks in advance,
Fred

Edited by FredP
Link to comment
On 1/17/2023 at 3:40 AM, FredP said:

Hey @tuanphan,

I would like to use a different image, and only for the main page. (the other pages don't matter).

I added the code and imported the image in design > custom CSS > manage custom file. The link works well, but the code doesn't! 😉

Thanks in advance,
Fred

Add to Design > Custom CSS

@media screen and (max-width:767px) {
[data-section-id="63987d07c71b4732240d4058"] {
    background-image: url(https://static1.squarespace.com/static/63987c03bf68e244c3d2b2ce/t/63bc4a45670e3049b76acef1/1673284168258/Invitation-Vertical.jpg) !important;
}
[data-section-id="63987d07c71b4732240d4058"] .section-background * {
    visibility: hidden !important;
}
}

 

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
  • Solution

It works like this! thanks a lot!  @tuanphan
I had to make a little twist.

@media screen and (max-width:767px) {
[data-section-id="63987d07c71b4732240d4058"] .section-background * {
    visibility: hidden !important;
}
}

 @media only screen and (max-width: 767px){
[data-section-id="63987d07c71b4732240d4058"] .section-background {
background-image: url(https://static1.squarespace.com/static/63987c03bf68e244c3d2b2ce/t/63bc4a45670e3049b76acef1/1673284168258/Invitation-Vertical.jpg);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
}

 

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.