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

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

相关推荐
思码梁田15 小时前
CSS transform 转换详解:translate、rotate、scale、skew 与 3D 变换一次讲清
前端·css·transform·skew·scale·translate·rotate
三天不学习1 天前
Tailwind CSS 快速入门(2026 版):从 v4 零配置上手,到「该不该用、怎么用好」的选型实战
前端·css·tailwind
htzyl2061 天前
前端阶梯——第九章、颜色、文本与背景
前端·css
htzyl2061 天前
前端阶梯——第八章、CSS入门与选择器
前端·css
传人2 天前
页面中心圆圈放大效果如何写
前端·css
被摘下的星星3 天前
CSS 基础说明
前端·css
传人once4 天前
网页文字滚动效果如何做
前端·css·html·jquery·html5
乌暮4 天前
拆解网页的底层逻辑:用费曼学习法讲透 HTML 与 CSS
前端·css·学习·html
传人once4 天前
多图片上传预览功能如何写
前端·css·html·jquery·html5
传人once4 天前
悬停旋转放大和位移效果如何写
javascript·css·动画