栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > Html/CSS > CSS教程

better-scroll实现菜单和内容联动的效果

CSS教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

1、基本使用




  
  
  
  document
  
  
    *{
      margin: 0;
      padding: 0;
      border: 0;
      outline: none;
      font-family: Arial;
      list-style: none;
      -webkit-font-smoothing: antialiased;
    }
    html, body, #app{
      height: 100%;
    }
    #app{
      padding: 20px 0;
      box-sizing: border-box;
    }
    .wrapper{
      display: flex;
      height: 100%;
      overflow: hidden;
      max-width: 1200px;
      margin: 0 auto;
    }
    .menu{
      width: 100px;
      height: 100%;
      padding-right: 20px;
    }
    .content{
      flex: 1;
      height: 100%;
      overflow: hidden;
      position: relative;
    }
    .menu-item{
      margin-bottom: 10px;
    }
    .menu-item-content{
      width: 100%;
      padding: 7px 0;
      text-align: center;
      border: 1px solid #ddd;
      border-radius: 2px;
      color: #333;
      cursor: pointer;
    }
    .active{
      border-color: #409EFF;
      background: #409EFF;
      color: #fff;
    }
    .content-item{
      margin-bottom: 20px;
    }
    .content-item-text{
      border-radius: 2px;
      border: 1px solid #ddd;
    }
    .content-item-text>img{
      width: 100%;
      vertical-align: middle;
    }
  


    
      
 
   

由于浏览器的兼容性,每个浏览器的滚动条样式都不尽相同,使用css样式修改的话,也只有部分浏览器能达到你想要的效果。

better-scroll模拟实现滚动条,父容器设置固定高度,并设置属性 overflow:hidden,让子元素超出父容器后隐藏,better-scroll作用在父容器上,通过transform:translate属性来让子元素滚动到想要的地方。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/214928.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号