Jump to content

Device specific HTML lines

Recommended Posts

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

Link to comment
  • Replies 2
  • Views 859
  • Created
  • Last Reply
@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 (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
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.

Link to comment

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.