如何更改清单页面Magento2中的列计数?

如何更改清单页面Magento2中的列计数?,magento2,Magento2,我想让产品列表页面使用3列,而不是4个默认列 我在我的Magento2网站上有一些分类,每个分类上都有一些产品。我希望它们显示为3列计数,但它始终显示为4个默认列计数,如何更改plz帮助我完成此操作。Magento 2没有将列计数设置为Magento 1的选项 要从4更改为3(对于基于Luma的主题),您需要更改CSS并重置图像大小 需要更改的CSS代码位于Magento_目录模块内,文件: _listings.less 它是这样的: .media-width(@extremum, @

我想让产品列表页面使用3列,而不是4个默认列


我在我的Magento2网站上有一些分类,每个分类上都有一些产品。我希望它们显示为3列计数,但它始终显示为4个默认列计数,如何更改plz帮助我完成此操作。

Magento 2没有将列计数设置为Magento 1的选项

要从4更改为3(对于基于Luma的主题),您需要更改CSS并重置图像大小

需要更改的CSS代码位于Magento_目录模块内,文件:

_listings.less
它是这样的:

    .media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__l) {
  .products-grid .product-item { width: 100%/5 }
  .page-layout-1column .products-grid .product-item { width: 100%/6 }
  .page-layout-3columns .products-grid .product-item { width: 100%/4 }
  .page-products .products-grid .product-items { margin: 0; }
  .page-products .products-grid .product-item {
    width: 24.439%;
    margin-left: calc(~"(100% - 4 * 32.439%) / 3");
    padding: 0;
    &:nth-child(3n+1) {
      margin-left: 0;
    }
  }
  .page-products.page-layout-1column .products-grid .product-item { width: 100%/5 }
  .page-products.page-layout-3columns .products-grid .product-item { width: 100%/4 }
}
要有3列,请将其更改为(我建议将此代码添加到_theme.less):

在这之后

/您的主题/etc/view.xml

更改小图像的宽度和高度。现在是240和300,把它改成300和330

刷新,就是这样

    .media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__l) {
  .products-grid .product-item { width: 100%/4 }
  .page-layout-1column .products-grid .product-item { width: 100%/5 }
  .page-layout-3columns .products-grid .product-item { width: 100%/3 }
  .page-products .products-grid .product-items { margin: 0; }
  .page-products .products-grid .product-item {
    width: 32.439%;
    margin-left: calc(~"(100% - 3 * 32.439%) / 2");
    padding: 0;
    &:nth-child(3n+1) {
      margin-left: 0;
    }
  }
  .page-products.page-layout-1column .products-grid .product-item { width: 100%/4 }
  .page-products.page-layout-3columns .products-grid .product-item { width: 100%/3 }
}