Jump to content

Resize one image with CSS

Recommended Posts

Site URL: https://sprout-dragonfly-f48x.squarespace.com/

Hi there,

I'm implementing an image in my website that I need only at 25 % of its size. On the desktop version I just implemented some empty space next to it to resize the whole thing.

However, on mobile the image appears full screen. I resized it via CSS to max-width of 25 % but it's either possible for all images (than it works fine but all other images are just as small) or I target only the specific image with data-image-id but that's not working. It resizes the image but the whole container stays the size of the full size image and therefore creates too much space underneath the now smaller image.

I've used this CSS code:

@media screen and (max-width: 640px) { [data-image-id="60e8168657d2352c927ec54d"] {
   max-width: 25%;
   max-height: 25%;
  }
}

In the attachment I show you a screenshot of what it looks like now on the website. I also attach an image of what I want it to look like (if I address all images it works perfectly but not when I try to address only the one).

Thank you for your help!

Sarah

Bildschirmfoto 2021-07-13 um 17.03.34.png

Bildschirmfoto 2021-07-13 um 17.00.07.png

Link to comment
  • Replies 19
  • Views 4.5k
  • Created
  • Last Reply

Top Posters In This Topic

16 hours ago, SarahHalbeisen said:

Site URL: https://sprout-dragonfly-f48x.squarespace.com/

Hi there,

I'm implementing an image in my website that I need only at 25 % of its size. On the desktop version I just implemented some empty space next to it to resize the whole thing.

However, on mobile the image appears full screen. I resized it via CSS to max-width of 25 % but it's either possible for all images (than it works fine but all other images are just as small) or I target only the specific image with data-image-id but that's not working. It resizes the image but the whole container stays the size of the full size image and therefore creates too much space underneath the now smaller image.

I've used this CSS code:

@media screen and (max-width: 640px) { [data-image-id="60e8168657d2352c927ec54d"] {
   max-width: 25%;
   max-height: 25%;
  }
}

In the attachment I show you a screenshot of what it looks like now on the website. I also attach an image of what I want it to look like (if I address all images it works perfectly but not when I try to address only the one).

Thank you for your help!

Sarah

Bildschirmfoto 2021-07-13 um 17.03.34.png

Bildschirmfoto 2021-07-13 um 17.00.07.png

Hi. What is access password?

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
On 7/14/2021 at 3:26 PM, SarahHalbeisen said:

Ah, sorry, the password is Hypnose2021

It looks like you solved with this CSS?

@media screen and (max-width: 640px) {
    .summary-thumbnail img {
        border-radius:50%;
        padding: 22px;
        max-width: 50%;
        margin: 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
1 hour ago, tuanphan said:

It looks like you solved with this CSS?

@media screen and (max-width: 640px) {
    .summary-thumbnail img {
        border-radius:50%;
        padding: 22px;
        max-width: 50%;
        margin: auto
    }
}

 

No, it's the image above – the one of the butterfly. I disabled the CSS that I used to adjust it, so you can see it. Now the image takes up the whole width of the screen and I would like to adjust it to 25% of its size.

If I do so, all images are smaller. However, I'd only need this one (here and on another site) to be smaller.

Thank you!

Link to comment
18 hours ago, SarahHalbeisen said:

No, it's the image above – the one of the butterfly. I disabled the CSS that I used to adjust it, so you can see it. Now the image takes up the whole width of the screen and I would like to adjust it to 25% of its size.

If I do so, all images are smaller. However, I'd only need this one (here and on another site) to be smaller.

Thank you!

Add to Design > Custom CSS

/* Butter fly size */
@media screen and (max-width:767px) {
div#block-yui_3_17_2_1_1625822684091_21731 {
    width: 25%;
    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
  • 11 months later...

Hi, I have the same problem with a flag image that I am trying to have on my home page. I can reduce the size with the spacer and it's fine on the desktop but the mobile version displays the image bigger. See screenshots attached. 

I tried to use the custom CSS you gave with the butterfly size, while changing the name for the name I chose for my image and also changing the "block yui..." but that does not work. No changes at all. What am I doing wrong here? 

Thank you!

desktop view.png

mobile view.jpeg

Link to comment
20 hours ago, NicoTHE said:

Hi, I have the same problem with a flag image that I am trying to have on my home page. I can reduce the size with the spacer and it's fine on the desktop but the mobile version displays the image bigger. See screenshots attached. 

I tried to use the custom CSS you gave with the butterfly size, while changing the name for the name I chose for my image and also changing the "block yui..." but that does not work. No changes at all. What am I doing wrong here? 

Thank you!

desktop view.png

mobile view.jpeg

Can you share link to page in screenshot?

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
On 6/22/2022 at 8:28 AM, NicoTHE said:

I have the same problem with a flag image that I am trying to have on my home page.

I don't see a flag icon. It is hard to provide a solution when we can't see the issue.

Quote

I can reduce the size with the spacer and it's fine on the desktop but the mobile version displays the image bigger.

In general spacer blocks are "removed" from the mobile view. As in most cases it doesn't make sense for them to be there because of limited space.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

There is no flag because I had to remove it since I don't have a solution for the flag size on mobile. Most of people now check a website from the cellphone, so I could not leave for them to see a huge flag when they arrive on the home page. That's why I added a screenshot of the flag on dashboard and then on mobile view so you can see how it looked like.

I know now that the spacer blocks are the problem for the mobile view, that's why I'm trying to see here if someone can help me find a solution with custom CSS instead that would fix the problem. 

Link to comment
17 minutes ago, NicoTHE said:

There is no flag because I had to remove it since I don't have a solution for the flag size on mobile.

Can you duplicate the page, add the flag, and point us to the duplicate? That would allow us to come up with the general code. It would need a last minute tweak (ids) once you added the flag to the real page.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
2 hours ago, NicoTHE said:

https://myadaandnicolas.squarespace.com/home-copy

https://treehouseexperts.com/home-copy

I hope this works, I'm trying to figure out how to share it with you 😆

The url doesn't work. Did you enable page yet?

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
1 hour ago, NicoTHE said:

that should work now page is enabled https://myadaandnicolas.squarespace.com/home-copy

 

Add to Design > Custom CSS

/* Flag on mobile */
@media screen and (max-width:640px) {
div#block-yui_3_17_2_1_1656710175672_8894 {
    width: 20%;
    float: right;
}
}

 

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.