print 模块小结
1. Print Google浏览器调试
-
打开The Command Menu ->More tools -> Rendering
-
Under Emulate CSS media type select print.
2. Print 分页折行
The properties: page-break-before, page-break-after and page-break-inside help to define how a document should behave when printed.
-
page-break-after: 设置在表格元素之后始终进行分页的分页行为
auto 默认。如果必要则在元素后插入分页符。
always 在元素后插入分页符。
avoid 避免在元素后插入分页符。
left 在元素之后足够的分页符,一直到一张空白的左页为止。
right 在元素之后足够的分页符,一直到一张空白的右页为止。
inherit 规定应该从父元素继承 page-break-after 属性的设置。注意: 您不能对绝对定位的元素使用此属性。( You cannot use this property on an empty <div> or on absolutely positioned elements.)
注意: 请尽可能少地使用分页属性,并且避免在表格、浮动元素、带有边框的块元素中使用分页属性。 -
page-break-before 设置在表格元素之前始终进行分页的分页行为
auto 默认值。如果必要则在元素前插入分页符。
always 在元素前插入分页符。
avoid 避免在元素前插入分页符。
left 在元素之前足够的分页符,一直到一张空白的左页为止。
right 在元素之前足够的分页符,一直到一张空白的右页为止。
inherit 规定应该从父元素继承 page-break-before 属性的设置。注意: 您不能对绝对定位的元素使用此属性。(You cannot use this property on an empty <div> or on absolutely positioned elements.)
注意:请尽可能少地使用分页属性,并且避免在表格、浮动元素、带有边框的块元素中使用分页属性。 -
page-break-inside 设置在表格元素内部避免进行分页的分页行为
auto 默认。如果必要则在元素内部插入分页符。
avoid 避免在元素内部插入分页符。
inherit 规定应该从父元素继承 page-break-inside 属性的设置。应用于:position 值为 relative 或 static 的非浮动块级元素。(You cannot use this property on absolutely positioned elements.)
注释:请尽可能少地使用分页属性,并且避免在表格、浮动元素、带有边框的块元素中使用分页属性。 -
使用position: absolute; 怎么办?
<body>
<div class="container">
<div class="div1">
<div class="div2">
<div class="div3">
<div class="div4">Div 1</div>
</div>
</div>
</div>
<div class="div1">
<div class="div2">
<div class="div3">
<div class="div4">Div 2</div>