Jump to content

Make a Web Element appear on mobile view only

Go to solution Solved by tuanphan,

Recommended Posts

Posted

Site URL: https://bluebird-porcupine-yzdg.squarespace.com/

Hello, I understand that you can have a web element appear only on desktop and to be hidden on mobile using this code:

@media only screen and (max-width:768px) {
div#block-BLOCK ID HERE>.sqs-block-content:first-child {
   display: none;
}
}

But I want to know if it is possible to show a web element (e.g. an image or text etc) just on mobile and not visible on desktop view? 

Please advise,

Many thanks!

Best,

Faiz

Posted

That's awesome thanks so much! Works perfectly.

So is the code is basically saying that, any device with a greater width than 769px the block element will not show?

I hope I have understood the code correctly?!

Posted

OK yes that's great! I'm trying to learn the code rather than just copying + pasting so thank you!

Should I change this code then to:

@media only screen and (min-width:768px) {
div#block-BLOCK ID HERE>.sqs-block-content:first-child {
   display: none;
}
}

what about the code to hide on mobile device, should this stay the same as here?

@media only screen and (max-width:768px) {
div#block-BLOCK ID HERE>.sqs-block-content:first-child {
   display: none;
}
}

Posted

OK great, I will change the code to hide on mobile device as here:

@media only screen and (max-width:767px) {
div#block-BLOCK ID HERE>.sqs-block-content:first-child {
   display: none;
}
}

Thank you so much for your time, I do appreciate your help. 

Posted
5 hours ago, scholarsayze said:

Sorry, just to add on here, as well as removing an element in mobile view, is it possible to remove an entire section so it doesn't appear on mobile view?

Which template do you use? or which SS version: 7.0 or 7.1?

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

Posted
On 6/10/2020 at 11:22 AM, scholarsayze said:

Sorry, just to add on here, as well as removing an element in mobile view, is it possible to remove an entire section so it doesn't appear on mobile view?

@scholarsayze yes it's possible to remove entire sections using CSS and media queries. 

Philadelphia, PA

👉 Squarespace Tutorials 

Chat/Message on FB Messenger for quickest responsehttps://m.me/dejaegherryan

 

  • Solution
Posted
18 hours ago, scholarsayze said:

Thanks Tuanphan I it's v7.1

@media screen and (max-width:767px) {
[data-section-id="abcxyztuan"] {
	display: none;
}
}

Find ID with this tool https://chrome.google.com/webstore/detail/squarespace-id-finder/igjamfnifnkmecjidfbdipieoaeghcff

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

  • 1 year later...
Posted
18 hours ago, meganntab said:

I followed the steps on this and, it worked, but I have a bunch of extra padding beneath the section I removed on the mobile version. Desktop version looks fine. Is there a way to fix this? 

Link: https://www.nationaltab.com/solutions

Hi. Target data-section-id, don't target block id.

Use this tool to find data section id. https://chrome.google.com/webstore/detail/squarespace-id-finder/igjamfnifnkmecjidfbdipieoaeghcff?hl=en

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

  • 2 years later...
Posted

The real question is why Squarespace makes designers jump through so many tedious hoops like it's 2010.

Just offer a completely obvious and simple toggle in section settings that allows me to display it on desktop or mobile like every other template builder has for over a decade! 

That's still woefully inadequate for truly useful functionality, but at least it's not forcing people to divine block IDs via browser inspection and then enter CSS that is far removed from the content and easy to lose track of, especially when having to do it a lot for an entire site. 

Arg, so annoying that I have to patiently explain this in 2024.

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.