@media only screen and (min-width: 1240px) { .woocommerce .related ul.products li.product, .woocommerce .related ul li.product, .woocommerce .upsells.products ul.products li.product, .woocommerce .upsells.products ul li.product, .woocommerce-page .related ul.products li.product, .woocommerce-page .related ul li.product, .woocommerce-page .upsells.products ul.products li.product, .woocommerce-page .upsells.products ul li.product { width: 23% !important; } .woocommerce ul.products li.product:nth-child(4n+1) { clear: both; }}@media only screen and (max-width: 767px) { .woocommerce .related ul.products li.product, .woocommerce .related ul li.product, .woocommerce .upsells.products ul.products li.product, .woocommerce .upsells.products ul li.product, .woocommerce-page .related ul.products li.product, .woocommerce-page .related ul li.product, .woocommerce-page .upsells.products ul.products li.product, .woocommerce-page .upsells.products ul li.product { width: 47% !important; } .woocommerce ul.products li.product:nth-child(2n+1) { clear: both; }}
@media only screen and (min-width: 1240px) { .woocommerce .related ul.products li.product, .woocommerce .related ul li.product, .woocommerce .upsells.products ul.products li.product, .woocommerce .upsells.products ul li.product, .woocommerce-page .related ul.products li.product, .woocommerce-page .related ul li.product, .woocommerce-page .upsells.products ul.products li.product, .woocommerce-page .upsells.products ul li.product { width: 23% !important; } .woocommerce ul.products li.product:nth-child(4n+1) { clear: both; } .woocommerce ul.products li.product:nth-child(3n+1) { clear: none !important; }}
Comments
to display 4 related products on desktop and 2 on mobile, you need to use the following css:
Anyway, to avoid unwanted behave, please replace the 1st declaration we gave you above with with the following css: