Magento – Magento 2 change number of items per row

itemsmagento2

I'm using Magento 2 with a custom theme , and I'm trying to change the number of items per row in the catalog. Now I'm having 3 items per row , and I'm trying to get 4.. what's the right file to edit to change that , as I have already changed from the admin panel – configuration – catalog – Products per page on list allowed to 6,12,16,22,26 , but there are still 3..

Best Answer

You can find below css styles in [Magento Blank Theme directory]/Magento_Catalog/web/css/source/module/_listings.less line 290 - 295

.products-grid .product-item { width: 100%/3 }
.page-layout-1column .products-grid .product-item { width: 100%/3 }
.page-layout-3columns .products-grid .product-item { width: 100%/3 }
.page-products .products-grid .product-item { width: 100%/3 }
.page-products.page-layout-1column .products-grid .product-item { width: 100%/3 }
.page-products.page-layout-3columns .products-grid .product-item { width: 100%/3 }

So you can copy this file into your theme directory, then change those widths like below.

.products-grid .product-item { width: 100%/4 }
.page-layout-1column .products-grid .product-item { width: 100%/4 }
.page-layout-3columns .products-grid .product-item { width: 100%/4 }
.page-products .products-grid .product-item { width: 100%/4 }
.page-products.page-layout-1column .products-grid .product-item { width: 100%/4 }
.page-products.page-layout-3columns .products-grid .product-item { width: 100%/4 }
Related Topic