English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
When printing documents, the 'page' before the CSS property-break-The 'before' property is located before the element and before the page break. This property applies to elements that generate boxes.块级Element. It does not apply to <p> that do not generate empty boxes.
The following table provides usage instructions and version history for this property, as well as the syntax for using this property in JavaScript scripts.
Default value: | auto |
---|---|
Applies to: | Block-level elements |
Inheritance: | None |
Animated production: | No.See also Animation properties。 |
版本: | CSS 2、3 |
语法:JavaScript | object.style.pageBreakBefore="always" |
属性的语法如下:
page-break-before: auto | always | avoid | left | right | initial | inherit
下面的示例演示了如何使用page-break-属性 before
@media print { h1 { page-break-before: always; } }测试看看‹/›
上面示例中的样式规则将分页行为设置为始终在<h1>元素之前分页,以便该元素始终出现在新页面的顶部。
下表描述了此属性的值。
值 | 描述 |
---|---|
auto | 如有必要,在元素之前插入一个分页符。这是默认值。 |
always | 始终在元素之前强制分页符。 |
avoid | 避免在元素之前分页。 |
left | 在元素之前强制分页一次或两个,以便下一页将成为左侧页面。 |
right | 在元素之前强制分页一次或两个,以便下一页将成为右侧页面。 |
initial | 将此属性设置为其默认值。 |
inherit | 如果指定,则关联元素采用其父元素page-break-值属性 before |
page-break-兼容性浏览器的before属性,下表中的数字表示支持该属性的浏览器最低版本号;所有主流浏览器均部分支持该属性。
|
警告: Internet Explorer 8和更早版本不支持这些值left和right; 任何一个值都被解释为值always。火狐,Chrome和Safari不支持的值avoid,left或right。
请参考以下教程:Types Media CSS。