自定义HTML页面的打印页眉/页脚输出

时间:2023-02-09 16:05:55

Is there a way to customize the text that is printed on the header and footer of every HTML page that you print, where the page number, URL, date, etc is printed ? (if you choose to print the headers and the footer from the print options).

有没有办法自定义打印在每个打印的HTML页面的页眉和页脚上的文本,其中打印页码,URL,日期等? (如果您选择从打印选项中打印页眉和页脚)。

The other solutions to display a header and a footer on every print page (using thead/tfoot and fixed positioned divs) don't seem to work on Chrome.

在每个打印页面上显示页眉和页脚的其他解决方案(使用thead / tfoot和固定定位的div)似乎在Chrome上不起作用。

Here are the print headers and footers highlighted on a print preview for google.com: 自定义HTML页面的打印页眉/页脚输出

以下是google.com打印预览中突出显示的打印页眉和页脚:

1 个解决方案

#1


-1  

Try this:

尝试这个:

@media screen {
  .print {
      display: none;
  }
}

@media print {
  .print {
      display: block;
  }
}

And add the .print class to the appropriate element or elements.

并将.print类添加到适当的元素或元素。

#1


-1  

Try this:

尝试这个:

@media screen {
  .print {
      display: none;
  }
}

@media print {
  .print {
      display: block;
  }
}

And add the .print class to the appropriate element or elements.

并将.print类添加到适当的元素或元素。