Solved

Dynamically resize multiple images to fit container

nagumi
Explorer
64 2 29

I have icons at the bottom of every product page. What I'd like is to have them dynamically resize to fit the container so they all fit on one line. Different products have different images (and different numbers of images.

 

Any ideas on how to do this? Site is www.gumpel.co.il

Screenshot 2021-06-13 224942.png

Accepted Solution (1)

KetanKumar
Shopify Partner
36843 3636 11978

This is an accepted solution.

@nagumi 

Sorry you are facing this issue, it would be my pleasure to help you.

1. Go to Online Store->Theme->Edit code
2. Asset->/theme.css ->paste below code at the bottom of the file.
this code apply for after 5 - 6 second

.et_pb_blurb_description img {
    max-inline-size: 100% !important;
    width: 20%;
    object-fit: contain;
    padding: 8px;
}

 

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing

View solution in original post

Replies 7 (7)

KetanKumar
Shopify Partner
36843 3636 11978

This is an accepted solution.

@nagumi 

Sorry you are facing this issue, it would be my pleasure to help you.

1. Go to Online Store->Theme->Edit code
2. Asset->/theme.css ->paste below code at the bottom of the file.
this code apply for after 5 - 6 second

.et_pb_blurb_description img {
    max-inline-size: 100% !important;
    width: 20%;
    object-fit: contain;
    padding: 8px;
}

 

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing
nagumi
Explorer
64 2 29

Kumar,

Thank you for the code! It does make the images resize dynamically, but they are still in two lines. How can I make all 7 images appear on one line, and 5 images for other products?

nagumi
Explorer
64 2 29

I tried to change the max size to "14%" (100/7) to fit all 7 and it works! Thank you so much Kumar!

One problem: for other products which have less icons (such as https://www.gumpel.co.il/products/evapo-rust-liquid) it still resizes them as if there's 7 icons.

 

Maybe the best way is to set up a snippet which shows the icons depending on which ones I select?

For example, in the code for product A I put "include icons: gloves, msds, ecofriendly, madeinamerica" and it shows those 4 and dynamically resizes for 4 icons.

KetanKumar
Shopify Partner
36843 3636 11978

@nagumi 

great thanks for update 

can you please change value 20% to as you like

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing
Lisabete
Visitor
2 1 3

Hi can you help me

KetanKumar
Shopify Partner
36843 3636 11978

@Lisabete 

Sorry you are facing this issue, it would be my pleasure to help you.

Welcome to the Shopify community!😊
Thanks for your good question.

Please share your site URL,
I will check out the issue and provide you a solution here.

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing

LitExtension
Shopify Partner
4860 1001 1135

Hi @nagumi

Please follow the steps:

- Step 1: You need to add all the images with the a tag around it, it's very important for the CSS to sync all. https://i.imgur.com/LJtl9Jf.png

- Step 2: Add CSS for the outer div: https://i.imgur.com/CVjqm00.png

Code: width: 100%;display: flex;

- Step 3: Add CSS for a tag: https://i.imgur.com/bpypOP2.png

Code: width: 100%;

- Step 4: Add CSS for img tag:https://i.imgur.com/ylMeU9R.png

Code: width: 100%;

If you do everything right, it will show like this: https://i.imgur.com/cCVsZ65.png

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify