目录

style pageBreakAfter 属性

示例

始终在每个 id="footer" 的 <p> 元素后设置分页符:

document.getElementById("footer").style.pageBreakAfter = "always";
亲自试一试 »

描述

pageBreakAfter 属性设置或返回元素后的分页行为(用于打印或打印预览)。

笔记:pageBreakAfter 属性对绝对定位的元素没有影响。分页符仅在打印预览或打印时可见。


浏览器支持

Property
pageBreakAfter Yes Yes Yes Yes Yes

语法

返回 pageBreakAfter 属性:

object.style.pageBreakAfter

设置 pageBreakAfter 属性:

object.style.pageBreakAfter = "auto|always|avoid|emptystring|left|right|initial|inherit"

属性值

Value Description
auto Insert a page break after the element if necessary. This is default
always Always insert a page break after the element
avoid Avoid a page break after the element
"" (empty string) Page break is not inserted after the element
left Insert one or two page breaks after the element, so the next page is considered a left page
right Insert one or two page breaks after 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-after 属性