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

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

相关推荐
掘金安东尼3 小时前
纯 CSS 实现弹性文字效果
前端·css
前端Hardy10 小时前
HTML&CSS&JS:打造丝滑的3D彩纸飘落特效
前端·javascript·css
前端Hardy10 小时前
HTML&CSS&JS:丝滑无卡顿的明暗主题切换
javascript·css·html
parade岁月1 天前
Tailwind CSS v4 — 当框架猜不透你的心思
前端·css
前端Hardy2 天前
HTML&CSS&JS:基于定位的实时天气卡片
javascript·css·html
程序员阿耶2 天前
5 个让 CSS 起飞的新特性,设计师看了直呼内行
css
前端Hardy2 天前
HTML&CSS:纯CSS实现随机转盘抽奖机——无JS,全靠现代CSS黑科技!
css·html
漂流瓶jz2 天前
BEM、OOCSS、SMACSS、ITCSS、AMCSS、SUITCSS:CSS命名规范简介
前端·css·代码规范
前端Hardy2 天前
HTML&CSS:高颜值产品卡片页面,支持主题切换
css·html
Never_Satisfied3 天前
在HTML & CSS中,nth-child、nth-of-type详解
前端·css·html