移动端左右两边滑动,并且去除滚动条

.html 

 <div class="yyjx_row">
                <div class="yyjx_item" >
                    <img :src="" alt="">
                    <span>篮球</span>
                </div>

              <div class="yyjx_item" >
                    <img :src="" alt="">
                    <span>篮球</span>
                </div>

               <div class="yyjx_item" >
                    <img :src="" alt="">
                    <span>篮球</span>
                </div>

               <div class="yyjx_item" >
                    <img :src="" alt="">
                    <span>篮球</span>
                </div>
            </div>

.less

  .yyjx_row {

   width:100%;
    display: -webkit-box;
    justify-content: flex-start;
    align-items: center;
    white-space: nowrap;

overflow-x: scroll;

overflow-y: hidden;

padding-bottom: 0.2rem;  兼容ios


    &::-webkit-scrollbar { //去除滚动条,设置滚动条的背景颜色为透明 
      background-color: transparent;

display:none;
    }
    .yyjx_item {
      width: 1.5rem;
      display: flex;
      flex-direction: column;
      align-items: center;
      position: relative;
      margin-right: 0.2rem;
      padding-right: 0;
      text-align: center;
      img {
        width: 100%;
        height: 1.5rem;
      }
      span {

        width: 100%;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.24rem;
        font-weight: bold;
        margin-bottom: 0.2rem;
      }
    }
  }

思路就是这样,有兴趣的可以去试试

猜你喜欢

转载自blog.csdn.net/dwb123456123456/article/details/82392205