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属性来让子元素滚动到想要的地方。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。


