问题
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