how to get related products in two columns on mobiles & 4 columns on dekstops?

Comments

  • Hi,

    to display 4 related products on desktop and 2 on mobile, you need to use the following css:
    @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;
        }
    }
  • edited December 2016
    hi, thanks for the code, the second set of code worked and the mobiles now display the related products in 2 columns, but the first set of code gave me this:image
  • Please put this code onto your site because we do not see it anywhere at this moment.
  • okay, i have put the code on to the backend. please check ASAP! 
  • Sorry but we still do not see it anywhere.
  • edited January 2017
    Sorry I had removed the code since it was on a live site and i had not gotten a response in two days, i have put the code back again on a cloned site: https://woocommerce-31034-69132-197811.cloudwaysapps.com/shop/strength/athos/seated-leg-curl-at-7090/   please check in this link now. sorry for the inceoncinece. 
  • Last 2 days it was a weekend and a new year and that's why we all were off.

    Anyway, to avoid unwanted behave, please replace the 1st declaration we gave you above with with the following css:
    @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;
        }
    }
Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.