当前位置:网站首页>PC端隐藏滚动条
PC端隐藏滚动条
2022-06-28 08:06:00 【庸懒】
在设置了overflow:auto的元素上使用伪元素选择器::-webkit-scrollbar,具体使用可看下面案例
<style type="text/css">
.li-group {
width: 500px;
height: 300px;
border: 1px solid red;
overflow-y: auto;
}
.li-group::-webkit-scrollbar {
display: none
}
li {
width: 100%;
height: 50px;
}
</style>
</head>
<body>
<ul class="li-group">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
</ul>
</body>
如果需要兼容其他浏览器可以使用下面的方法
.outer-container,.content {
width: 200px; height: 200px;
}
.outer-container {
position: relative;
overflow: hidden;
}
.inner-container {
position: absolute; left: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.inner-container::-webkit-scrollbar {
display: none;
}
<div class="outer-container">
<div class="inner-container">
<div class="content">
......
</div>
</div>
</div>
本质上就是在最外层再套一个overflow:hidden的盒子, 内部内容的尺寸和外部嵌套的盒子一样即可。
边栏推荐
- 抗洪救灾,共克时艰,城联优品捐赠10万元爱心物资驰援英德
- 匿名页的反向映射
- Study notes 22/1/18
- Doris学习笔记之介绍、编译安装与部署
- Is it reliable to open an account by digging money? Is it safe?
- Kubernetes cluster command line tool kubectl
- HJ整数与IP地址间的转换
- Design of DSP image data stream
- Upgrade HDP spark to spark 2.4.8 without upgrading ambari
- The solution of "user account control to continue, please enter administrator user name and password" appears in win10 Professional Edition
猜你喜欢

Airflow2.1.1 summary of the pits stepped on in actual combat!!

Section 5: zynq interrupt

SQL analysis (query interception analysis for SQL optimization)

Ambari (VIII) --- ambari integrated impala document (valid for personal test)

本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献

Section 9: dual core startup of zynq

Redis cluster deployment and application scenarios

Kubernetes cluster command line tool kubectl

ROS notes (09) - query and setting of parameters

kubernetes集群命令行工具kubectl
随机推荐
B_QuRT_User_Guide(29)
SLAM中常用的雅克比矩阵J
软件测试与质量期末复习
券商注册开户靠谱吗?安全吗?
Section 5: zynq interrupt
Dataset filling data, and the use of rows and columns
Devops foundation chapter Jenkins deployment (II)
Upgrade HDP spark to spark 2.4.8 without upgrading ambari
HJ字符个数统计
HJ character count
城联优品向英德捐赠抗洪救灾爱心物资
Ambari (VIII) --- ambari integrated impala document (valid for personal test)
GPIO configuration of SOC
HJ explicit random number
Prometheus monitoring (I)
【js】-【节流、防抖函数】
Jacobian matrix J commonly used in slam
kubernetes集群命令行工具kubectl
The solution of "user account control to continue, please enter administrator user name and password" appears in win10 Professional Edition
Vagrant installation