H5 CSS 滚动条隐藏 (横向/纵向)

1、纵向

全局隐藏- 最外层css样式上增加 -webkit-scrollbar

.time_plan_detail_warp {
  height: 100vh;
  overflow-y: scroll;
  &::-webkit-scrollbar {
    display: none;
  }
}

2、横向

思路:代码取巧,两层div,固定高度,内高度比外高度多20px,然后padding-bottom: 20px

vue,开箱即用的代码(代码有自身的逻辑部分,可忽略)

<template>
  <div class="time_profit_warp">
    <div class="time_profit_center">
      <div
        v-for="(item, index) in iconArray"
        :key="index"
        :class="['profit_item', iconArray.length > 4 ? 'item_more_four' : '']"
      >
        <div class="profit_img" @click="toPrpofit(item.target)">
          <!-- <img :src="item.img" alt="" /> -->
        </div>
        <div class="profit_word">横向滚动</div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator';

@Component({ name: 'ProfitIcon' })
export default class ProfitIcon extends Vue {
  private iconArray: any = ['0', '1', '2', '3', '4', '5'];

  toPrpofit(target: any) {
    if (target) {
      window.location.href = target;
    }
  }
}
</script>
<style lang="scss">
.time_profit_warp {
  padding-bottom: r(24);
  height: r(220);
  overflow: hidden;
  border: 1px solid white;
  .time_profit_center {
    height: r(240);
    display: flex;
    justify-content: flex-start;
    overflow: auto;
  }
  .profit_item {
    display: flex;
    padding-bottom: r(40);
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    min-width: r(168);
    border: 1px solid green;
    .profit_img {
      width: r(96);
      height: r(96);
      border: 1px solid red;
      border-radius: 50%;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .profit_word {
      margin-top: r(16);
      font-size: r(26);
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: rgba(255, 255, 255, 0.6);
      line-height: r(32);
      white-space: nowrap;
      text-align: center;
    }
  }
  .profit_item:last-child {
    margin-right: 0;
  }
  .item_more_four {
    min-width: r(150);
  }
}
</style>

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值