Html CSS:自动分页符?
有没有一种方法可以自动检测内容何时侵犯页面边距,然后使用CSS强制分页符?我有一个有边框和一些内容的DIV:Html CSS:自动分页符?,html,css,Html,Css,有没有一种方法可以自动检测内容何时侵犯页面边距,然后使用CSS强制分页符?我有一个有边框和一些内容的DIV: <div id="container"> This content could spill into the bottom margin of the printed page.... </div> 是否有执行以下操作的@print规则: +----------+ | | | page 1 | | | | conte
<div id="container">
This content could spill into the bottom margin of the printed page....
</div>
是否有执行以下操作的@print
规则:
+----------+
| |
| page 1 |
| |
| content |
| |
| this over|
+----------+
+----------+
|flows and |
|the CSS |
|makes a |
|new page |
|with a |
|border |
+----------+
如果可能的话,我希望避免编写手动强制中断的规则,一个好的解决方案应该(一直)回到IE8/旧版Firefox。谢谢 我认为没有办法拆分一个div来实现这一点。一种方法是打破内部元素,例如段落 例如:
<div id="print">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
#print {
border: 2px solid #000;
}
@media print {
#print {
border: 0;
}
#print p {
border: 2px solid #000;
}
#print p:last-child {
page-break-before: always;
}
}
印刷版本为:
+-----------+
| |
| page 1 |
| |
| content |
| |
|with border|
+-----------+
+-----------+
| |
| page 2 |
| |
| content |
| |
|with border|
+-----------+
你用谷歌搜索过这个吗?是的,我已经在那里着陆了。他似乎手动使用.page break类选择器强制分页符,这正是我试图避免的。
+-----------+
| |
| page 1 |
| |
| content |
| |
|with border|
+-----------+
+-----------+
| |
| page 1 |
| |
| content |
| |
|with border|
+-----------+
+-----------+
| |
| page 2 |
| |
| content |
| |
|with border|
+-----------+