开发者

How to style HTML to display 2 data cards to a printed page?

I have an input document of XML data that will resolve nicely into data cards that can be printed 2 to a page (or maybe 4 to a page, or 9 to a page, or something).

What's the best way for me to style the data for them to be printed that way? For exampl开发者_运维技巧e, how can I say "Make this div extend 1/3 of the way down a printed page"?


HTML isn't really intended for exact display in that way. Having said that...

If you know the paper size, you can perhaps be clever with the units in a print stylesheet (i.e. using cm rather than px or em). You may even be able to use percentages and not worry about the paper size too much, but I haven't tested this. It would also depend on the content, its layout, and how different the paper sizes might be.

An example of using percentages (to force a <div> to be 1/3 the page height) would be specifying height: 33% in the CSS.

It is also possible to force page breaks in CSS, by specifying page-break-after: always (or page-break-before: always if that is more convenient).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜