header and footer in each page in print mode with css

前端 未结 4 1716
北海茫月
北海茫月 2021-02-01 19:28

I have a web application and it has a report that might exceed one page and I would like to print a header and footer in every page. i find and try this: Repeating a report head

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-01 20:22

    You can set a position: fixed; header and footers so that it will repeat on each page

    For Example

    @media screen { header.onlyprint, footer.onlyprint{ display: none; /* Hide from screen */ } } @media print { header.onlyprint { position: fixed; /* Display only on print page (each) */ top: 0; /* Because it's header */ } footer.onlyprint { position: fixed; bottom: 0; /* Because it's footer */ } }

提交回复
热议问题