美文网首页
flex布局 平均分布,最后一行左对其

flex布局 平均分布,最后一行左对其

作者: 九旬大爷的梦 | 来源:发表于2020-05-18 14:51 被阅读0次

html

<view class="box container">
  <view class="user-item" wx:for="{{userList}}" wx:key="index">
    <image class="user-avatar" src="{{item.avatarUrl}}"></image>
    <view class="user-name">{{item.nickName}}</view>
  </view>
</view>

css

.box {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.box:after {
    content: "";
    flex: auto;
 }

.user-item {
  display: inline-block;
  margin: 10rpx;
}

.user-item .user-avatar {
  width: 74rpx;
  height: 74rpx;
  border-radius: 50%;
}

.user-item .user-name {
  color: #333;
  font-size: 24rpx;
  text-align: center;
  width: 74rpx;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

js

 userList: [{
        avatarUrl: 'https://images.unsplash.com/photo-1578513492798-0f8a1ac3e1f0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80',
        nickName: '二狗'
      }]

参考:

相关文章

网友评论

      本文标题:flex布局 平均分布,最后一行左对其

      本文链接:https://www.haomeiwen.com/subject/emepactx.html