利用flex布局横向滚动

2018-11-22  本文已影响0人  柏龙

默认小于4条信息左右两端对齐 超出添加滚动

以下是图例:


两端对齐.png 左右滚动.png

wxml代码

<view class="padding-style">
    <view class='overflow-company-second'>
      <view class="special-list">
        <view class='active'>发现简书</view>
        <view>我的关注</view>
        <view>消息评论</view>
        <view>投稿请求</view>
        <view>喜欢和赞</view>
        <view>赞赏和付费</view>
      </view>
    </view>
  </view>

wxss代码

.padding-style{
  padding: 0 28rpx;
}
.overflow-company-second{
  overflow: hidden;
  height: 88rpx;
  border-bottom: 1px solid #ccc;
}
.special-list{
    line-height: 88rpx;
    font-size: 30rpx;
    display: flex;
    overflow-x: auto;
    justify-content: space-between;
    padding-bottom: 40rpx;
}
.special-list>view{
  text-align: center;
  font-size: 30rpx;
  color: #283B42;
  font-weight: bold;
  flex-basis: 172rpx;
  flex-shrink: 0;
  white-space: nowrap;
}
.special-list>view.active {
  position: relative;
}
.special-list>view.active::before {
  content: "";
  display: block;
  clear: both;
  width: 120rpx;
  height: 6rpx;
  background-image: linear-gradient(90deg, #ea6f5a 58%, #eebeb6 100%);
  border-radius: 40rpx;
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
}

主要使用的标签

上一篇 下一篇

猜你喜欢

热点阅读