如何使用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.效果

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

相关推荐
coding随想15 小时前
深入Modernizr源码:揭秘CSS伪类检测的底层逻辑
前端·css
程序员林北北16 小时前
【前端进阶之旅】50 道前端超难面试题(2026 最新版)|覆盖 HTML/CSS/JS/Vue/React/TS/ 工程化 / 网络 / 跨端
前端·javascript·css·vue.js·html
Amumu121381 天前
CSS简介
前端·css
温轻舟2 天前
前端可视化大屏【附源码】
前端·javascript·css·html·可视化·可视化大屏·温轻舟
糖糖TANG2 天前
学成在线 案例练习
前端·css
1314lay_10072 天前
color: var(--el-color-success); CSS里面使用函数
前端·css
Kyl2n2 天前
【密码口令保存小工具】
javascript·css·css3
银烛木2 天前
黑马程序员前端h5+css3
前端·css·css3
听海边涛声2 天前
CSS3 图片模糊处理
前端·css·css3
小黑的铁粉2 天前
使用 min-height: 0 为什么可以防止 flex 项目溢出?
前端·css