Avoid a page break inside the <p> element with id="footer":
document.getElementById("footer").style.pageBreakInside = "avoid";
Try it Yourself »
The pageBreakInside property sets or returns the page-break behavior inside an element (for printing or print preview).
Note: The pageBreakInside property has no effect on absolutely positioned elements. The page break is only visible in a print preview or when printing.
Tip: Avoid page-break properties inside tables, floating elements, and block elements with borders.
Property | |||||
---|---|---|---|---|---|
pageBreakInside | Yes | Yes | Yes | Yes | Yes |
Return the pageBreakInside property:
object.style.pageBreakInside
Set the pageBreakInside property:
object.style.pageBreakInside = "auto|avoid|initial|inherit"
Value | Description |
---|---|
auto | Insert a page break inside the element if necessary. This is default |
avoid | Avoid a page break inside an element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | auto |
---|---|
Return Value: | A String, representing the page-break behavior inside an element when printing |
CSS Version | CSS2 |
CSS reference: page-break-inside property
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!