如何使用HTML在文档的每个打印页面上打印页眉和页脚? [英] How to use HTML to print header and footer on every printed page of a document?

查看:1450
本文介绍了如何使用HTML在文档的每个打印页面上打印页眉和页脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在每个打印页面上打印自定义页眉和页脚的HTML网页?

Is it possible to print HTML pages with custom headers and footers on each printed page?

我想在Red,Arial中添加UNCLASSIFIED

I'd like to add the word "UNCLASSIFIED" in Red, Arial, size 16pt to the top and bottom of every printed page, regardless of the content.

要澄清,如果文档打印在5页上,

To clarify, if the document was printed onto 5 pages, each page should have the custom header and footer.

有人知道是否可以使用HTML / CSS?

Does anybody know if this is possible using HTML/CSS?

推荐答案

如果你选择要作为页脚的元素并将其设置为position:fixed和bottom:0,当页面打印时,它将重复该元素每个打印页的底部。

If you take the element that you want to be the footer and set it to be position:fixed and bottom:0, when the page prints it will repeat that element at the bottom of each printed page. The same would work for a header element, just set top:0 instead.

例如:

<div class="divFooter">UNCLASSIFIED</div>

CSS:

@media screen {
  div.divFooter {
    display: none;
  }
}
@media print {
  div.divFooter {
    position: fixed;
    bottom: 0;
  }
}

这篇关于如何使用HTML在文档的每个打印页面上打印页眉和页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆