当前位置:网站首页>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的盒子, 内部内容的尺寸和外部嵌套的盒子一样即可。
边栏推荐
- Update pip to the latest version
- Redis uses sentinel master-slave switching. What should the program do?
- pip 更新到最新的版本
- Connaissez - vous le protocole TCP (2)?
- Design of DSP image data stream
- asp. Net upload image path and image name
- Flex layout
- Uvcgan: unt vision transformer cycle-consistent Gan for unpropared image-to-image translation
- Devops foundation chapter Jenkins deployment (II)
- SOC clock configuration
猜你喜欢

Three step problem of leetcode

云原生:云计算技术再次升级 开启全面云开发时代

A single node obtains the lock lock of the order number

Design of DSP image data stream

MySQL row format parsing

Cloud native: cloud computing technology is upgraded again to open an era of comprehensive cloud development

Uvcgan: unt vision transformer cycle-consistent Gan for unpropared image-to-image translation

SQL analysis (query interception analysis for SQL optimization)

Software testing and quality final review

Prometheus + grafana + MySQL master-slave replication + host monitoring
随机推荐
HJ prime factor
MySQL single table access method
Vagrant installation
Study notes 22/1/17
MySQL implements transaction persistence using redo logs
Unity - Pico开发 输入系统等相关API的使用---C#篇
Prometheus monitoring (I)
Porting ucosiii to stm32f429
sql分析(查询截取分析做sql优化)
Flex layout
Explanation and application of instr() function in Oracle
Software design of power control board
HJ字符串排序
Is it reliable for flush to register and open an account? Is it safe?
MySQL tablespace parsing
本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献
【js】-【DFS、BFS应用】-学习笔记
你了解TCP协议吗(二)?
Eslint 语法监测关闭
sql主从复制搭建