- UID
- 7996
- 精华
- 积分
- 13
- 威望
- 点
- 宅币
- 个
- 贡献
- 次
- 宅之契约
- 份
- 最后登录
- 1970-1-1
- 在线时间
- 小时
|
发表于 2022-7-30 18:02:29
|
显示全部楼层
Hide scroll bar when not needed
there is no one dedicated CSS rule to Hide scroll bar when not needed. However, this is possible with a few browser-specific CSS rules. To hide the scrollbar and keep scrolling functionality, apply the following CSS to the body (for the entire page) or a specific element.
How to Hide the Scrollbar in CSS (and Prevent Scrolling)
To hide the scrollbar and disable scrolling, we can use the CSS overflow property. This property determines what to do with content that extends beyond the boundaries of its container.
- /* hide scrollbar and prevent scrolling */
- #div-1 { overflow: hidden; }
- #div-2 { overflow: visible; }
- /* other styling */
- div {
- border: solid 5px black;
- border-radius: 5px;
- height: 100px;
- margin: 20px;
- width: 300px;
- }
- * {
- background-color: #EAF0F6;
- color: #2D3E50;
- font-family: 'Avenir';
- }
复制代码
To hide the vertical scrollbar and prevent vertical scrolling, use overflow-y: hidden like so:
- /* hide vertical scrollbar and prevent vertical scrolling */
- div {
- overflow-y: hidden;
- /* other styling */
- border: solid 5px black;
- border-radius: 5px;
- height: 300px;
- width: 300px;
- }
- img { height: 500px; }
- /* other styling */
- * {
- background-color: #EAF0F6;
- color: #2D3E50;
- font-family: 'Avenir';
- }
复制代码
|
|