-->

Add borders to each printed page with CSS?

2019-06-20 15:14发布

问题:

Is it possible in CSS or js to emulate the following format in printed media (eg showing borders for each page, with a page number and some text in the corner, with the content nicely split - and not chopped in half)?

I have been using page-break-after to split the content up, but havn't found a way to add this kind of border/page number to each page. This only needs to work in WebKit.

For further information, the reason I am doing this is I am printing HTML documents to PDF using wkhtml.

回答1:

Trying using the print media type.

@media print {
...
}

Information and tutorial on leveraging the print media type.

Tutorial on CSS page-breaking for print