Jump to content

Different Home Pages for Mobile vs Desktop on 7.1?

Go to solution Solved by tuanphan,

Recommended Posts

Posted

Hello, I recently transitioned from 7.0 to 71.  On my old site I had a different home page with vertical images and another homepage with horizontal images.  This code below was used to automatically switch the home page depending if the visitor was on mobile or desktop.  Is there an equivalent set of CSS code or functionality in 7.1?

 

/* show home page block dependent on screen size * / 
@media only screen and (max-width: 780px) { #home { display: none; } } 
@media only screen and (min-width: 781px) { #home-mobile/mobile { display: none; } }
 

Thanks!

  • Replies 7
  • Views 1.5k
  • Created
  • Last Reply

Top Posters In This Topic

Posted (edited)

Hi alfredomoraphoto

You need to find the page-id and apply the CSS on it for keep it different,

If you share the website URL I provide you the page-id of you're home page

 

👨‍✈️Professional Squarespace Developer - Custom Code

Contact:

Submit Request

 

Edited by MySquare24
  • Solution
Posted
On 1/6/2024 at 12:00 AM, alfredomoraphoto said:

I'm going to delete that new section since my site is live.  Let me know when you want me to add it back.  I tried the plugin but it won't let me add the code to the image block.

Suppose you have 2 sections on homepage, top and second

To hide top on desktop, add this code to Website Tools (Under Not Linked) > Custom CSS

@media screen and (min-width:768px) {
	body.homepage article section:first-child {
		display: none !important;
}
}

To hide second on mobile, use this code

@media screen and (max-width:767px) {
	body.homepage article section:nth-child(2) {
		display: none !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!)

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.