本文介绍了哪些浏览器支持使用CSS和页面中断元素的分页处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用page-break-inside CSS指令,它的类是附加到一个div标签或一个表标签(我认为这可能只适用于块元素,在这种情况下,它会必须是表)。

I'm trying to use the page-break-inside CSS directive, the class of which is to be attached to a div tag or a table tag (I think this may only work on block elements, in which case it would have to be the table).

我已经尝试了所有的教程,应该准确地描述如何做到这一点,但没有什么工作。这是一个浏览器支持的问题或者任何人实际上已经得到这个工作,CSS的确切位看起来像这样:

I've tried all the tutorials that supposedly describe exactly how to do this, but nothing works. Is this an issue of browser support or has anyone actually gotten this working, the exact bit of CSS looks like this:

@media print {

  .noPageBreak {
     page-break-inside : avoid;
  }
}


推荐答案

Safari 1.3和更高版本(不知道4)做支持page-break-inside(尝试,或者看这里:)。也不是Firefox 3或IE7(不知道约8)。

Safari 1.3 and later (don't know about 4) do not support page-break-inside (try it, or see here: http://reference.sitepoint.com/css/page-break-inside). Neither do Firefox 3 or IE7 (don't know about 8).

在实际意义上,支持这个属性是SO spotty,它没有意义在这一点上使用它。

In a practical sense, support for this attribute is SO spotty, it doesn't make sense to use it at all at this point. You'd be lucky if even 10% of your visitors have browsers that can support this.

我使用的解决方案是添加

The solution I used was to add

page-break-after:always

-breakerdiv在哪里你想要休息。这是相当无聊的,我知道,因为它不做你想要的,并导致内容没有到达打印页面的底部,但不幸的是没有一个更好的解决方案(证明我错了!

to certain divs, or add a "page-breaker" div in where you want breaks. This is quite ham-handed, I know, because it doesn't do quite what you want, and causes content to not reach the bottom of the printed page, but unfortunately there isn't a better solution (prove me wrong!).

另一种方法是创建一个样式表,删除所有无关的元素( display:none ),以在一个主柱中流动。

Another approach is to create a stylesheet that removes all extraneous elements (display:none) and causes the main content to flow in one main column. Basically, turn it into a single column, text-only document.

最后,在为打印机设计样式时,避免使用浮点和列,它可以使IE(和FF) 。

Finally, avoid floats and columns when styling for printers, it can make IE (and FF) act wacky.

这篇关于哪些浏览器支持使用CSS和页面中断元素的分页处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 12:58