How to hide the scroll bar and with the content ramaining scrollable? [duplicate]

泪湿孤枕 提交于 2019-12-24 06:41:02

问题


I want to print my html page into a PDF file, but don't want the scroll bar showing there in the PDF file. And my page have a scrollable body, so if I set this:

* {
   overflow: hidden;
}

The body will be incomplete in the final pdf file. So if there is a way just prevent the scrollbar from showing but the content still scrollable?


回答1:


There is a CSS rule that can hide scrollbars in Webkit-based browsers (Chrome and Safari). That rule is:

.element::-webkit-scrollbar { width: 0 !important }

There is a CSS rule that can hide scrollbars in IE 10+. That rule is:

.element { -ms-overflow-style: none; }

There used to be a CSS rule that could hide scrollbars in Firefox, but it has since been deprecated. That rule was:

.element { overflow: -moz-scrollbars-none; }



回答2:


You can set display of scrollbar to none by:

::-webkit-scrollbar {
    display: none;
}

This will hide all the scrollbars without disabling scrolling.

Edit: this only works on chrome, for a better explanation you can check this answer Hidding Scrollbar



来源:https://stackoverflow.com/questions/42268436/how-to-hide-the-scroll-bar-and-with-the-content-ramaining-scrollable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!