【CSS】flex布局实现一行展示三个子元素并两端对齐

代码微信小程序里实现,效果如下:

WXML:

<view class="goods-Box">
  <view class="list">
    <view class="list-item" wx:for="{{productList}}" wx:key='item' data-item="{{item}}">
      <image src="{{item.logourl}}" mode="aspectFill"></image>
      <view class="item-title">{{item.name}}</view>
      <view class="item-price">¥{{item.price}}
      </view>
    </view>
  </view>
</view>

WXSS:

.goods-Box {
  background-color: #f9f9f9;
  padding: 32rpx;
  overflow: hidden;
}

.goods-Box .list {
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  flex-flow: wrap;
}

.goods-Box .list-item {
  width: 216rpx;
  border-radius: 8rpx;
  margin-bottom: 24rpx;
}

.goods-Box .list-item image {
  width: 100%;
  height: 216rpx;
  display: block;
  background: #ddd;
  border-radius: 16rpx;
}

.goods-Box .list-item .item-title {
  color: #333;
  font-size: 28rpx;
  margin: 16rpx 0;
  display: -webkit-Box;
  display: -moz-Box;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  -webkit-Box-orient: vertical;
  -webkit-line-clamp: 2;
}

.goods-Box .list-item .item-price {
  color: #F86363;
  font-size: 32rpx;
  overflow: hidden;
}

.goods-Box .list-item .item-price text {
  color: #aaa;
  font-size: 28rpx;
  text-decoration: line-through;
  margin-left: 8rpx;
}

 

相关文章

Css3如何实现鼠标移上变长特效?(图文+视频)
css3怎么实现鼠标悬停图片时缓慢变大效果?(图文+视频)
jquery如何实现点击网页回到顶部效果?(图文+视频)
css3边框阴影效果怎么做?(图文+视频)
css怎么实现圆角边框和圆形效果?(图文+视频教程)
Css3如何实现旋转移动动画特效