Jump to content

Different Home Pages for Mobile vs Desktop on 7.1?

Go to solution Solved by tuanphan,

Recommended Posts

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!

Link to comment
  • Replies 7
  • Views 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

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

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.