Jump to content

Can I control the size of images on mobile devices?

Recommended Posts

I'm wondering if anybody knows a way to control the size of images in an Image Block when displayed on mobile devices.

To be specific, the images are (on large browsers) small mugshots of members of our team. They're inserted on the page one after another and on mobile devices they are scaled to the width of the screen. I'm hoping to make them a bit smaller than this as on iPads and other tablets they become rather intimidating.

Here's the page in question if it's useful:

http://www.superhet.net/about/

Thanks

Assistant at Superhet.

Link to comment
  • Replies 10
  • Views 31k
  • Created
  • Last Reply

This isn't a native Squarespace 6 option, but if you're handy with coding you could make it happen in developer mode. Just use a media query to target screens below a certain size; it might look something like this:


@media screen and (max-device-width: 480px) {
 img {
   float: left;
   width: 200px;
 }
}

Here's a really great article on using media queries if you'd like to look into this a bit more.

http://www.alistapart.com/articles/responsive-web-design/

Developer Evangelist at Squarespace.

Link to comment

Thank you for your suggestion. Unfortunately it doesn't seem to work! I don't understand why as your CSS seems to make perfect sense. I have read about media queries before but never used one. I assume Squarespace already uses this sort of thing out of the box?

Is it possible something could be conflicting with this code? I have had to use '!important' before to override stubborn Squarespace code.

I tried this sort of thing to get around stubborn code:

@media screen and (max-device-width: 480px) { #block-8253851efba5ab80d69a img { float: left; width: 100px !important; }}

Assistant at Superhet.

Link to comment

Hi Joe,

I actually didn't think that exact code would work, it was more like a suggestions to steer you in the right direction. It's definitely possible some of your theme's code is overriding this rule. You should get a little more specific with your CSS declaration to make sure that doesn't happen - try giving the images an ID and then using that to target the images in the CSS.

-Kevin

Developer Evangelist at Squarespace.

Link to comment
  • 1 year later...
  • 1 year later...

I FOUND IT!!!!! I had the same problem and found NO solution that worked for me! Finally a found a solution myself! instead of using coding, just adapt the image. f.ex. if you had an image 400400 blown up on mobile devices, but perfect on desktop, you add white space to both sides of the images (not within squarespace but with other programs). the result is f.ex. a 800400 image which will result in a PERFECT mobile image. (de dimensions are an example of course)

the images will look smaller on mobile, because the site is using the white space from both sides of the image!

if you do it right, i'm sure it will work for you as well!

Link to comment
  • 11 months later...

Duh! Thank you henrybouci! It worked like a charm!!

I added the white border + resized the photo a little and it's now showing at the size that I wanted. For some reason I thought Squarespace would overrule any resizing but no, it was as simple as that. The white border was fundamental though.

Thanks again!

Link to comment
  • 3 years later...
  • 5 months later...

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.