如何使用css隐藏掉滚动条

1.解决方案

在滚动元素上再包裹一个父元素,然后,该元素添加如下代码:

(注:PC端浏览器滚动条为8px)使元素偏移原来位置8px,目的就是将滚动条区域移动到父元素边框外面,然后,父元素上添加overflow:hidden即可

css 复制代码
margin-right: -8px;
margin-bottom: -8px;
height: 100%;
overflow: scroll;

2.示例代码

css 复制代码
.menus-part--wrapper{
  height: calc(100vh - 80px) !important;
  overflow: hidden;
  .menus-part-content{
    margin-right: -8px;
    margin-bottom: -8px;
    height: 100%;
    overflow: scroll;
  }
}

3.效果

选中元素后,绿色区域就是被移动到父元素外的滚动条。

相关推荐
传人once12 小时前
网页文字滚动效果如何做
前端·css·html·jquery·html5
乌暮14 小时前
拆解网页的底层逻辑:用费曼学习法讲透 HTML 与 CSS
前端·css·学习·html
传人once1 天前
多图片上传预览功能如何写
前端·css·html·jquery·html5
传人once1 天前
悬停旋转放大和位移效果如何写
javascript·css·动画
听风3472 天前
windplay网页创意实验场
css·html·创意·website·windplay
福兮说2 天前
设计稿是 #4A7C6F,页面量出来是 #4B7C6F:HEX、HSL、透明度、canvas 来回转的七个坑
前端·javascript·css·canvas
weixin_448290252 天前
书庐开发实战教学
javascript·css·html
传人2 天前
悬停旋转放大和位移效果如何写
前端·javascript·css
geovindu3 天前
css: Timeline scribble
前端·css·iphone
易朵朵3 天前
CSS 格式化上下文
css·vue.js