商城项目商品展示一行多个商品贴边样式例子:一行5个商品1200px,每个商品230px,向右间距12.5px

display: flex;
flex-direction: row;

flex-wrap: wrap;

justify-content: space-between;

这样设置当一行不足5个商品时,商品不能居左显示,改进办法时去掉justify-content: space-between;

此时每个商品有margin-right,在商品渲染时加判断,当是第5个商品是设置没有间距

if((i+1)%5==0){

  marginR="marginRight";
    }else{
    marginR="";

  }

.marginRight{

margin-right:0 !important;

}

相关文章:

  • 2021-04-01
  • 2021-05-04
  • 2021-07-06
  • 2022-12-23
  • 2021-09-25
  • 2022-02-09
  • 2022-02-09
猜你喜欢
  • 2021-07-25
  • 2021-05-10
  • 2021-10-06
  • 2021-11-25
  • 2021-04-30
  • 2022-01-20
相关资源
相似解决方案