Danilo Pádua
Danilo Pádua

Reputation: 398

How to make the header and footer without repeating in print for N pages?

I'm struggling to repeat the header and footer on each print page. No problem necessarily be a table, most like it was, someone has any idea how to do? And i dont know how many pages it will be, can be n pages.

enter image description here

TRY: jsfiddle.net/7ZGVv/111

Upvotes: 3

Views: 3952

Answers (2)

Adam Buchanan Smith
Adam Buchanan Smith

Reputation: 9449

Well since no-one seems to think it is a dup, I will post the code here to prove it. See a working example here http://a-b-smith.com/

html

<h1>test 1</h1>
<h1>test 2</h1>
<h1>test 3</h1>
<h1>test 4</h1>
<h1>test 5</h1>
<h1>test 6</h1>
<div class="divFooter">
<h1>Footer</h1>
</div>
<div class="divHeader">
<h1>Header</h1>
</div>

CSS note I added a page break in between each of the <h1> to simulate multiple pages

@media print {
  h1 {
    page-break-after: always;
  }
  div.divFooter {
    position: fixed;
    bottom: 0;
  }
  div.divHeader {
    position: fixed;
    top: 0;
  }
  body > h1 {margin-top: 100px;}
}

@media screen {
  div.divFooter, div.divHeader {
    display: none;
  }
}

Upvotes: 2

Gerald Chablowski
Gerald Chablowski

Reputation: 472

HTML and CSS have no support for printing page header and footers in print. You may be able to simulate it with:

  • tables
  • fixed position blocks

This solution have each bug and caveat in different browser.

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

Upvotes: 1

Related Questions