简体   繁体   English

打印时在Chrome中隐藏垂直滚动条

[英]Hide Vertical Scrollbar in Chrome while printing

How can I remove the scrollbar while I print report in Chrome Browser. 在Chrome浏览器中打印报告时如何删除滚动条。 Here is my code: 这是我的代码:

<style>
     @media print {
         @page {
             size: A4 portrait;
             margin:1cm;
         }
</style>

Here is the picture: 这是图片:

在此处输入图片说明

overflow: hidden is the css property you are looking for. overflow: hidden是您要查找的CSS属性。 It removes the scrollbar and removes overflowing content. 它删除滚动条并删除溢出的内容。 See: https://developer.mozilla.org/en/docs/Web/CSS/overflow 请参阅: https//developer.mozilla.org/en/docs/Web/CSS/overflow

<style>
     @media print{
         @page {
             size: A4 portrait;
             margin:1cm;
             overflow: hidden;
            }
     }
</style>

Or try to set the overflow hidden without depending on the media query: 或者尝试不依赖于媒体查询就将溢出设置为隐藏:

html { overflow: hidden; }

If this does not help for printing, maybe have a look at the answer of following question: How to hide the scroll bar and with the content ramaining scrollable? 如果这对打印没有帮助,请查看以下问题的答案: 如何隐藏滚动条并保留可滚动的内容?

As mentioned there you could try to set the width of the scrollbar to zero for webkit browsers. 如前所述,您可以尝试将webkit浏览器的滚动条宽度设置为零。

This is the solution I found: 这是我发现的解决方案:

 @media print{
            @page {
                size: A4 portrait;
                margin:1cm;
            }
            ::-webkit-scrollbar {
                display: none;
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM