简体   繁体   English

如何在Safari浏览器的打印页面(window.print())功能中隐藏页眉和页脚?

[英]How to hide header & footer in printing page (window.print()) function in safari browser?

I need to hide header and footer section in printing page .我需要在打印页面中隐藏页眉和页脚部分。 I have used below css code to hide the header and footer .我使用下面的 css 代码来隐藏页眉和页脚。

 @page    {
  size: auto;  
  margin: 0;  
 }

Its only working in chrome & Firefox.它仅适用于 chrome 和 Firefox。 But not working in safari.但不在 safari 中工作。 How can I fix this ?我怎样才能解决这个问题 ? Please help me to find solution.请帮我找到解决方案。

According to caniuse.com , @page is not supported by Safari.根据caniuse.com@page不受 Safari 支持。 Actually, size property is not supported well in IE/Edge and Firefox, so it is better not to use it.实际上,IE/Edge 和 Firefox 不支持size属性,因此最好不要使用它。

To hide header and footer in print page.在打印页面中隐藏页眉和页脚。 Maybe you can use media query:也许您可以使用媒体查询:

@media print {
  header,footer { 
    display: none; 
  }
}

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

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