简体   繁体   English

HTML / CSS-打印时避免单元分裂

[英]HTML/CSS - Avoiding cell splitting when printing

I want to print an HTML table. 我想打印一个HTML表。

Unfortunately, when I do, cells (rows) are often cut between two pages. 不幸的是,当我这样做时,单元格(行)通常被切成两页。 Also, browsers seem to trample over the page-break-inside property without any care, so that won't work. 此外,浏览器似乎毫不留意地踩了page-break-inside属性,因此这行不通。

The code in question: 有问题的代码:

<table>
<tr><td colspan="2">HEY YALL!</td></tr>
<tr><td>A!</td><td>B</td></tr>
</table>

Sorry -- I think there is no great way to go here -- the web still isn't made for printing. 抱歉-我认为这里没有什么好办法-仍然不是用于打印的网络。

One work-around for IE is to emulate version 8, so the page-break-inside: avoid will work. IE的一种解决方法是模拟版本8,因此page-break-inside: avoid将起作用。 There's also a bit about windows and orphans settings. 还有一些关于Windows和孤立对象的设置。 More here: http://msdn.microsoft.com/en-us/library/dd433064%28v=vs.85%29.aspx 此处更多内容: http : //msdn.microsoft.com/zh-cn/library/dd433064%28v=vs.85%29.aspx

You can also look for HTML+CSS - to - PDF conferters. 您也可以寻找HTML + CSS-to-PDF提交者。 I've seen a lot of different implementations of that sort of thing. 我已经看到了很多类似的事情。

One thing I've done in the past also is to change the content-type to .doc and stream the HTML out to MS Word (because that's what my users have, and Word can read HTML now.). 我过去做过的一件事是将内容类型更改为.doc并将HTML流式传输到MS Word(因为这是我的用户所拥有的,并且Word现在可以读取HTML。)。 This works OK. 这样就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM