HTML元素超出部分滚动, 并隐藏滚动条

在customerList容器里面,brandItem超出部分滑动,并且隐藏滑动条 (项目需要 应用在移动端)

<div  class="customerList" v-if="isShowCustomer==true">
      <div class="customerItem" v-for="brandItem in Brands" @click="getBrand(brandItem)">{{brandItem.BrandName}}</div>
</div> 
一,利用 css 3 的新特性 -webkit-scrollbar, 但是这种方式不兼容 火狐 和 IE
.customerList {
    .px2rem(252);
    height: @px2rem;
    overflow-x: hidden;
    overflow-y: scroll;
  }

  .customerList::-webkit-scrollbar {
    display: none;
  }

(仅实现超出部分滑动 可用css样式 overflow: auto;)

二,利用内外层嵌套, 模拟, 兼容所有浏览器, 相对于方法一比较麻烦, 使用时不能对滚动条声明任何样式

html部分:

<div  class="customerList" v-if="isShowCustomer==true">
      <div>    
          <div class="customerItem" v-for="brandItem in Brands" @click="getBrand(brandItem)">{{brandItem.BrandName}}</div>
      </div>
</div> 

css部分:

.customerList {
  /* 父容器设置高度, 并超出部分不显示 */
    .px2rem(252);
    height: @px2rem;
    overflow: hidden;
  }

 .customerList >div{
     /* 子容器比父容器高*/
         .px2rem(352);
          height: @px2rem;
          overflow-y: scroll;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,684评论 1 92
  • day01­_起源和结构 结构:Xhtml xml 表现:CSS 行为:DOM ECMAScript 以上都属于W...
    Sakura_明妃阅读 4,980评论 0 1
  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML标准。 注意:讲述HT...
    kismetajun阅读 28,024评论 1 45
  • 关于css常见问题,大多是移动端的。 简单的排版规则:条目与条目之间空两行,每条内容部分分段空一行。标点符号全部用...
    苏水儿阅读 10,463评论 0 9
  • 在时间管理方面优先完成重要但不紧急的事产生的积极意义:首先,重要说明不得不干,不紧急说明不需要立刻、马上就干。分解...
    遇见金哥阅读 2,900评论 0 1