Jump to content

Device specific HTML lines

Recommended Posts

Posted

Site URL: https://insidefukushima.org/home

Hello,

I'm using page header code injection to add a line of text to a "gallery" page. Unfortunately gallery pages do not allow for text boxes, so I had to use custom HTML lines. I was able to insert the text, however the text does not look good on mobile, so I would like for it to be only visible for desktop users.

This is the HTML:

<html>
   <head>
   </head>
   <body>
      <style>
         div.center {
         position: fixed;
         left: 50%;
         bottom: -21px;
         transform: translate(-50%, -0%);
         margin: 0 auto;
         }
      </style>
      <div class="center">
         <h2>Click on the information "i" button for photo details.</h2>
      </div>
   </body>
  </html>

I know that its possible to use custom CSS to make changes visible to devices within a certain range using "@media screen and (min-width: )", which I used to increase the size of the information button to display media descriptions for desktops only. However, I'm not aware of any way to do this through the page header code injection.

Is there any way to make HTML lines device specific through the page header code injection? Perhaps I'm approaching this from the wrong angle. The page that I am talking about is https://insidefukushima.org/home. You can see the text that I added under the image.

Thank you!

F944759E-BA0D-4EA0-B7D7-CC51CDFC8DA4_1_105_c.jpeg

Screen Shot 2020-12-07 at 5.36.49 PM.png

  • Replies 2
  • Views 920
  • Created
  • Last Reply
Posted
@media only screen and (max-width: 640px) {
  .center {
  	display: none;
  }
}

here is sample of how media query working, you can learn a bit from here 

https://www.w3schools.com/css/css_rwd_mediaqueries.asp

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> 🤖 Ask me anything

Posted
1 hour ago, bangank36 said:

@media only screen and (max-width: 640px) {
  .center {
  	display: none;
  }
}

here is sample of how media query working, you can learn a bit from here 

https://www.w3schools.com/css/css_rwd_mediaqueries.asp

This worked perfectly, thank you. I was trying to use the "@media only" before but it appears I was not wrapping it with style tags for HTML. I had only previously used it in the custom CSS tool.

I will bookmark that page, that is very useful.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.