css隐藏滚动条的方法
时间: 2023-09-11 07:03:22 浏览: 155
CSS怎么隐藏滚动条(三种方法)
5星 · 资源好评率100%
隐藏滚动条的方法有多种。一种方法是在`<body>`标签中添加样式`style="overflow-x:hidden"`来隐藏水平滚动条,或者添加样式`style="overflow-y:hidden"`来隐藏垂直滚动条。另一种方法是在被包含页面中添加样式`<style> html { overflow-x:hidden; } </style>`来隐藏水平滚动条。然而,在标准 DTD 下,`body{ overflow-x:hidden; }`是不被允许的。\[1\]还有一种方法是在`<style>`标签中添加样式`body { overflow-x:hidden; overflow-y:hidden; }`或者`html { overflow-x:hidden; overflow-y:hidden; }`来同时隐藏水平和垂直滚动条。\[2\]另外,可以给需要滚动的元素设置样式`overflow-x:hidden; overflow-y:scroll`来隐藏水平滚动条并显示垂直滚动条。\[3\]
#### 引用[.reference_title]
- *1* *2* [css隐藏滚动条方法](https://blog.csdn.net/weixin_30929295/article/details/98815856)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [CSS隐藏滚动条的方法](https://blog.csdn.net/csdn_cai_csdn/article/details/78838949)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文