zoukankan      html  css  js  c++  java
  • 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;
    }
    
  • 相关阅读:
    IO基础
    集合框架
    数据结构基础
    进程和线程
    matlab绘制三维图形
    matlab figure 窗口最大化
    Matlab中的fread函数
    matlab中fopen 和 fprintf函数总结
    matlab中findstr,strfind,strcmp,strncmp区别与联系
    matlab取消和添加注释以及一些快捷键
  • 原文地址:https://www.cnblogs.com/jessie-xian/p/11596737.html
Copyright © 2011-2022 走看看