Site logo

Archived topic

Woocommerce image size (created with shortcodes)

16 replies · Started by roadlink on February 14, 2021

Viewing posts 1–15 of 17

Hello,

I set 300px as image size in customize > woocommerce. https://prnt.sc/zhjln1
It is working very well in shop pages, categories and also Related/Upsell Columns. Here

But I have an issue in main page.
I create columns in main page by woocommerce shortcodes. Like this.
[products limit="4" columns="4" orderby="id" order="DESC"]
But the product images are not exactly 300px and there is gap between them.
https://prnt.sc/zhju0j

Any suggestion to fix it?

Can I use category design in main page? like this.

Hi there,

try this CSS:

.home .woocommerce ul.products li.product {
  margin-right: 10px;
  width: calc(25% - 10px);
}

Adjust the 10px to suit.

the weird thing is, woocommerce use 300pcs images but resize them to 272px.
I don't understand why.

Hi Tertas,

We could add a media query to limit the CSS only works for desktop.

@media (min-width: 769px) {
    .home .woocommerce ul.products li.product{
         width: calc(25% - 15px);
    }
    .home .woocommerce ul.products li.product:not(.last) {
         margin-right: 15px;
    }
    .woocommerce ul.products {
        margin-left: 7px;
        margin-right: -7px;
    }
}

Let me know :)

Hello Ying,

Worked well, thanks.

It is weird that it is not working out of the box.

No problem :)

I just realized that this CSS makes right space 25px.
15px from container + 10px from css code.

https://prnt.sc/zrp8v8

Do you need us to help with anything? Let me know :)

Hi Ying,
If you have time sure need help :)

This code add 10px margin for last product too. "margin-right: 10px;"
Which means last product have total 25px margin to container.
But it should be 15px like left product.

Have a nice day. Sorry to keep you more busy :(
Btw, Latest code makes the last product smaller. https://prnt.sc/zuwl1i

Lets keep the margin gap to 15px then you can do this:

@media (min-width: 769px) {
    .home .woocommerce ul.products li.product{
         width: calc(25% - 15px);
    }
    .home .woocommerce ul.products li.product:not(.last) {
         margin-right: 15px;
    }
}

Hello David,

Thanks for the code, but result is similar.
https://prnt.sc/zvw465

I tried to put arrows regarding the issue.

regards

This archived topic is closed to new replies.