How do I keep a <td> element from appearing across multiple pages when printed from IE?

亡梦爱人 提交于 2019-12-06 02:46:09

问题


I have an HTML table of data where each cell can have multiple lines of text. When the table is printed, it's possible for a row to be broken up so that some of the data appears at the bottom of the first page and some appears at the top of the next. Is there an equivalent to Word's "keep together" functionality that will prevent a page break from happening within a table row? I would think this would be a common problem, but the only "answer" I could find was hidden on a certain hyphenated web site. :)

Update: The data will be viewed using IE 7, which it appears does not handle the "page-break-inside" property correctly (if at all). Are there alternatives? Is this something jQuery can help with?


回答1:


try:

The CSS2-friendly way to do it would be
td { page-break-inside: avoid; }

see the page-break-inside definition

from: http://channel9.msdn.com/forums/TechOff/35322-Keep-with-next-when-printing-HTML-tables/




回答2:


You may use CSS mediatypes to create printer friendly pages. A simple example is given in the following page. I believe it would help you solving the problem. http://martybugs.net/articles/print.cgi



来源:https://stackoverflow.com/questions/1223860/how-do-i-keep-a-td-element-from-appearing-across-multiple-pages-when-printed-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!