http://www.w3.org/TR/CSS21/page.html
When a page break splits a box, the box's margins, borders, and padding have no visual effect where the
split occurs.
当分页符分割一个块状元素时,该元素的margin、border和padding将不可见。
In the normal flow, page breaks can occur at the following places: 1. In the vertical margin between block-level boxes. When an unforced page break occurs here, the used
values of the relevant 'margin-top' and 'margin-bottom' properties are set to '0'. When a forced page
break occurs here, the used value of the relevant 'margin-bottom' property is set to '0'; the relevant
'margin-top' used value may either be set to '0' or retained. 2.Between line boxes inside a block container box. 3.Between the content edge of a block container box and the outer edges of its child content (margin
edges of block-level children or line box edges for inline-level children) if there is a (non-zero) gap
between them.
Note: It is expected that CSS3 will specify that the relevant 'margin-top' applies (i.e., is not set to
'0') after a forced page break.
在一般的文档流里面,分页符可以发生在下面几个地方:
1.在不同块状元素的垂直范围 当不是强制分页符插入的时候(auto),其margin-top和margin-bottom将重置为0; 当是强制分页符(always)插入的时候,其margin-bottom将重置为0,margin-top将可能会重置为0;
2.在块状元素内的的行内元素之间;
3.如果有非零的间隙在块状容器的内容边缘和其子元素的外部边缘之间,则分页符插在它们之间;
注意:预测,在css3将不对margin-top重置为0。
These breaks are subject to the following rules:
•Rule A: Breaking at (1) is allowed only if the 'page-break-after' and 'page-break-before' properties of
all the elements generating boxes that meet at this margin allow it, which is when at least one of them
has the value 'always', 'left', or 'right', or when all of them are 'auto'.
•Rule B: However, if all of them are 'auto' and a common ancestor of all the elements has a 'page-break-
inside' value of 'avoid', then breaking here is not allowed.
• Rule C: Breaking at (2) is allowed only if the number of line boxes between the break and the start of
the enclosing block box is the value of 'orphans' or more, and the number of line boxes between the break
and the end of the box is the value of 'widows' or more.
•Rule D: In addition, breaking at (2) or (3) is allowed only if the 'page-break-inside' property of the
element and all its ancestors is 'auto'.
这些分割样式将服从下面的规则:
规则A:当至少有一个元素设置了 'always', 'left', 或 'right', 或所有的都设置为 'auto',且遇见一个范围允许插
入页分隔符,则在1的地方插入.
规则B:但是,如果所有的都设置为“auto”,且有一个父元素设置 'page-break-inside' 的值为 'avoid',则不允许
插入页分隔符;
规则C:如果设置了'orphans' 或“window”的值且满足条件,则允许在2的地方插入分隔符;
规则D:另外,在2或3的地方插入分隔符,仅仅是块状元素和其所有父元素的 'page-break-inside' 设置都为auto的时
候;
If the above does not provide enough break points to keep content from overflowing the page boxes, then
rules A, B and D are dropped in order to find additional breakpoints.
If that still does not lead to sufficient break points, rule C is dropped as well, to find still more
break points.
如果上面的规则没有提供足够的分页符插入点去阻止内容溢出页面,为了去找到更多的插入点,则抛弃ABD规则; 如果依然没有找到足够的插入点,为了找到更多的插点,C规则也将抛弃;
1、如果内容不确定多长,内容可能不在一页上,应该禁止使用绝对或者相对定位;
2、使用page-break-inside:avoid阻止某个块状元素内部分页,实现整体处在一个页上;
3、尽量使用table元素布局,打印机对table的分页处理机制比div好,因为table是天生用来显示数据的,而打印天生是
用来打印数据的;
4、不要使用rowspan去设置某行的高度;