要隐藏滚动条,请使用-webkit-,因为主要浏览器(Google Chrome、Safari 或更新版本的 Opera)都支持它。下面列出了其他浏览器的许多其他选项:
- -webkit-(Chrome、Safari、较新版本的 Opera):
.element::-webkit-scrollbar { width: 0 !important }
- -moz-(火狐):
.element { overflow: -moz-scrollbars-none; }
- -ms-(Internet Explorer +10):
.element { -ms-overflow-style: none; }
隐藏滚动条之前要考虑的要点:
- 最好仅当所有内容都可见时才隐藏滚动条,否则用户可以跳过内容
- 避免在网页上水平滚动并且不要隐藏水平滚动条,因为它们会使内容难以阅读
- 如果需要隐藏滚动条:在首屏显示所有重要信息。用户可能经常决定是否要停留在不滚动就可以看到的内容上。
注意:隐藏滚动条的实际例子是 Facebook 聊天窗口。
例子:
GeeksforGeeks is a computer science portal. It is a good platform to learn programming. It is an educational website. Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful.输出:
例子:
hide scrollbar 输出: