目录

style pageBreakBefore 属性

示例

始终在每个 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 属性