打印HTML表格而无需在两页之间拆分行 [英] Printing HTML tables without splitting a row across two pages

查看:107
本文介绍了打印HTML表格而无需在两页之间拆分行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从OS X上的Internet Explorer(各种版本)和Safari的HTML表中打印一些数据.暂时忽略Safari.

I need to print some data in an HTML table from Internet Explorer (various versions) and Safari on OS X. Ignoring Safari for the moment.

当打印的表的行数超过页面上的容量时,页面的最后一行通常会被拆分成第一行的一部分和下一页的其余部分.

When printing a table that has more rows than can fit on a page, the last row on the page is often split with part of the row on the first page and the rest of the row on the next page.

这看起来很丑.有办法避免吗?

This looks ugly. Is there a way to avoid it?

我一直在搜索,到目前为止,我已经找到 page-break-before:always ,但是我不确定那不是我要找的东西,因为我不会无法预先知道页面上将容纳多少行.例如根据内容的不同,行可能更高或更短,并且用户可能以纵向或横向模式进行打印.我至少假设使用A4,但是如果用户使用美国字母或其他纸张尺寸,则会带来更大的不确定性.另外,打印机边距又如何呢?

I've been searching around and so far I've found page-break-before: always, but I'm not sure if that's what I'm looking for, since I won't know up front how many rows will fit on the page. e.g. the rows might be taller or shorter depending on the content and the user might be printing in portrait or landscape mode. I'm assuming A4 at least, but if the user was using US letter or some other paper size it would introduce even more uncertainty. Also, what about printer margins?

那么有办法解决吗?还是我只需要猜测将容纳多少行并在那之后强制分页?还能行吗?

So is there a way around this? Or do I just have to guess how many rows will fit and force a page break after that? Will that even work?

推荐答案

您可能想玩 page-break-before/after:auto . page-break-inside 是理想的选择,但大多数浏览器不支持 .

You probably want to play around with page-break-before/after: auto. page-break-inside would be ideal but its not supported by most browsers.

在这里看看 http://www.westciv.com/style_master/academy/css_tutorial/advanced/printing.html 获取一些不错的信息.

Take a look here http://www.westciv.com/style_master/academy/css_tutorial/advanced/printing.html for some good info.

这篇关于打印HTML表格而无需在两页之间拆分行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆