Jump to content

Prevent images from resizing on mobile

Recommended Posts

Hi there - I see a few posts like this but can't figure out what code to add to prevent images from resizing on mobile view. Can someone help me? I am not sure what the 'class' of image is for "your-image-class" in the below code:

@media screen and (max-width: 640px) {
  img.your-image-class {
    width: 100%; /* Adjusts image width to 100% of the container */
    height: auto; /* Keeps the aspect ratio intact */
  }
}

 

Anyone have any guidance? 

Link to comment
  • Replies 5
  • Views 909
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 month later...

I am struggling with the same issue. www.therutlader.com - the second image (Bike Reg) in mobile view is stretching the page, I am trying to get it to roughly half the size.

Link to comment
10 hours ago, JWSKS said:

I am struggling with the same issue. www.therutlader.com - the second image (Bike Reg) in mobile view is stretching the page, I am trying to get it to roughly half the size.

You can use a CSS code like this to Website > Website Tools > Custom CSS

@media screen and (max-width:767px) {
div#block-yui_3_17_2_1_1654723628836_4556 {
    max-width: 100px;
    margin: 0 auto;
}
}

 

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.