始终在每个 id="footer" 的 <p> 元素之前设置分页符:
document.getElementById("footer").style.pageBreakBefore = "always";
亲自试一试 »
pageBreakBefore 属性设置或返回元素之前的分页行为(用于打印或打印预览)。
笔记:pageBreakBefore 属性对绝对定位的元素没有影响。分页符仅在打印预览或打印时可见。
Property | |||||
---|---|---|---|---|---|
pageBreakBefore | Yes | Yes | Yes | Yes | Yes |
返回 pageBreakBefore 属性:
object.style.pageBreakBefore
设置 pageBreakBefore 属性:
object.style.pageBreakBefore = "auto|always|avoid|emptystring|left|right|initial|inherit"
Value | Description |
---|---|
auto | Insert a page break before the element if necessary. This is default |
always | Always insert a page break before the element |
avoid | Avoid a page break before the element |
"" (empty string) | Page break is not inserted before the element |
left | Insert one or two page breaks before the element, so the next page is considered a left page |
right | Insert one or two page breaks before the element, so the next page is considered a right page |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
默认值: | 汽车 |
---|---|
返回值: | 一个字符串,表示打印时元素之前的分页行为 |
CSS版本 | CSS2 |
CSS 参考:page-break-before 属性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!