How to use HTML to print header and footer on every printed page of a document?

前端 未结 20 1353
迷失自我
迷失自我 2020-11-21 16:51

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

I\'d like to add the word \"UNCLASSIFIED\" in Red, Arial, size 16pt to the t

20条回答
  •  你的背包
    2020-11-21 17:15

    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.

    For example:

    UNCLASSIFIED

    CSS:

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

提交回复
热议问题