Display WooCommerce Products in Single Column on Mobile Devices

Last modified Nov 26, 2020
Difficulty Beginner
Language CSS
Category
WooCommerce Products in One Column on Mobile Devices

Once a WooCommerce store is on its way, and a selection of products are added to the back end, the shop page will, by default, display the products listed in two columns. This can be frustrating as the product title and featured image end up looking rather small on mobile devices. 

While there’s no back end plugin setting for creating a single column layout for your WooCommerce shop, thankfully, a bit of CSS will do the trick. If you want to change WooCommerce and make a single product page with one column, this tutorial is for you!

Today, you’ll learn how to use a few CSS lines to edit the Divi shop module so that it displays a single column on mobile devices.

Want to skip the step-by-step tutorial and grab the code? Jump straight ahead to the code library and copy the code.

Showcase Your WooCommerce Products in a Single Column on Mobile Devices

By default, WooCommerce products presented via the Divi Shop module will display in two columns on mobile devices. This can make for a crowded look and feel on mobile. Also graphic details of featured images will be lost as they’ll display at a small size.

In this tutorial, we’ll be working with CSS adding media queries into the Advanced tab of the Divi Shop module. Media queries, sometimes referred to as @medias are lines of CSS that take care of responsiveness for various device sizes and orientations.

Often, websites are designed with desktop or laptop widths and heights in mind. When the same web layout is displayed on a mobile or tablet, the design will likely distort. To remedy this, lines of CSS code called media queries are added to the stylesheet of the child theme. These media queries will target a specific web element and instruct it on how it should display at a particular breakpoint.

Between mobiles and tablets in both portrait and landscape orientation, there are countless combinations of device widths and heights that need to be taken into account.

In this tutorial, you’ll be targeting mobile devices (screen sizes with a maximum width of 767 pixels), and instructing select web elements to display in a certain way.

If you haven’t set up a child theme yet, you can download a free one from the Divi Space site. If you need a refresher on what child themes are and why they’re important, read our guide.

Step 1: Add a Shop Module to a Page Layout

Begin by adding a Divi Shop module to a new page. On desktop, the layout will display as such:

WooCommerce Products in One Column on Mobile Devices - Divi Shop module on desktop

We’ve added a Divi shop module of eight products in four columns to a Shop page

On mobile, the same layout will display as follows:

WooCommerce Products in One Column on Mobile Devices - Divi Shop module default mobile

By default, the Divi Shop module will display two columns

To change this to a single column, open the Divi Shop module and add the CSS code to the Advanced tab > Custom CSS box/

 

As soon as the code is added, the Divi Shop module will display in a single column on mobile:

WooCommerce Products in One Column on Mobile Devices - Divi Shop module CSS added

Once the CSS is added to the Divi Shop module, the mobile display will show a single column

In just a few seconds, you would have fully transformed the mobile experience of your WooCommerce store. Now, your customers can see clearly which products you’re selling as they browse through your products.

We’ll be releasing a brand new plugin that’ll help you set the column count for your Divi and WooCommerce store without using code. Instead of working with lines of code you can simply set the number of columns you’d like for desktop, tablet and mobile using the Divi builder’s settings. It couldn’t be easier! Look out for our plugin in the Divi Space store!

Did you enjoy this Divi tutorial? Let us know which snippets you’d like us to create! Comment your snippet wish list below!

CSS

@media (max-width: 767px) {
 body.et-db #et-boc .et-l .et_pb_shop ul.products.columns-1 li.product, 
 body.et-db #et-boc .et-l .et_pb_shop ul.products.columns-2 li.product, 
 body.et-db #et-boc .et-l .et_pb_shop ul.products.columns-3 li.product, 
 body.et-db #et-boc .et-l .et_pb_shop ul.products.columns-4 li.product, 
 body.et-db #et-boc .et-l .et_pb_shop ul.products.columns-5 li.product, 
 body.et-db #et-boc .et-l .et_pb_shop ul.products.columns-6 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_related_products ul.products.columns-1 li.product,  
 body.et-db #et-boc .et-l .et_pb_wc_related_products ul.products.columns-2 li.product,  
 body.et-db #et-boc .et-l .et_pb_wc_related_products ul.products.columns-3 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_related_products ul.products.columns-4 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_related_products ul.products.columns-5 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_related_products ul.products.columns-6 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_upsells ul.products.columns-1 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_upsells ul.products.columns-2 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_upsells ul.products.columns-3 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_upsells ul.products.columns-4 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_upsells ul.products.columns-5 li.product, 
 body.et-db #et-boc .et-l .et_pb_wc_upsells ul.products.columns-6 li.product {
        width: 100%!important;
        margin-right: 0%!important;
    }
}


@media all and (max-width: 767px) {
     .woocommerce-page ul.products li.product:nth-child(n) {
        margin: 0 0 11.5%!important;
        width: 100%!important;
    }
}

 

Does this snippet (still) work?

Please let us know in the comments if everything worked as expected. We have tested this code with the Version: 4.5.3 of the Divi Theme.
If you think this code saved you time, we will be happy to receive a comment!

___

License: This snippet contains code from the Divi Theme, copyright https://elegantthemes.com, and Woocommerce Plugin by Automatic modified by Divi Space, November 5, 2020. Licensed under the GNU General Public License, no warranty; click here for details.

Your Comments

1 Comment

  1. Antoine

    Yo ! Still working on 4.8.1. Thks guys !

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Receive notifications about our new blog posts.