前端瀑布流布局实现

    list:[
     'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3933500633,3793764385&fm=26&gp=0.jpg',
     'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4100872422,3923134513&fm=26&gp=0.jpg',
     'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3133265356,1603273935&fm=26&gp=0.jpg',
     'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3673889381,371529118&fm=11&gp=0.jpg',
     'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3472316311,4110746464&fm=26&gp=0.jpg',
     'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3086736054,3375812831&fm=26&gp=0.jpg'
    ]

需要渲染的数组为list

  <view class="box">
    <view class="item">
      <image src="{{item}}" wx:for="{{list}}" wx:for-index="idx" wx:if="{{idx%2===0}}" wx:key="item" class="item1" mode="widthFix">{{item}}</image>
    </view>
    <view class="item">
      <image src="{{item}}" wx:for="{{list}}" wx:for-index="idx" wx:if="{{idx%2===1}}" wx:key="item" class="item2" mode="widthFix">{{item}}</image>
    </view>
  </view>

设置css

.box{
  display: flex;
  width: 100%;
  justify-content: space-around;
}
.item{
  display: flex;
  flex-direction: column;
  width: 45%;
}
.item image{
  margin: 10px 0;
  width: 100%;
}
.item1{
  width: 100%;
}
.item2{
  width: 100%;
}

完成效果

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值