English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

manual of CSS reference

CSS @rules

大全 of CSS properties

page CSS-break-Usage and examples of 'before' property

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
语法:JavaScriptobject.style.pageBreakBefore="always"

page-break-语法使用 before

属性的语法如下:

page-break-before: auto | always | avoid | left | right | initial | inherit

下面的示例演示了如何使用page-break-属性 before

  @media print {
   h1 {
    page-break-before: always;      
   }
  }
测试看看‹/›

上面示例中的样式规则将分页行为设置为始终在<h1>元素之前分页,以便该元素始终出现在新页面的顶部。

注意:该page-break-属性 before仅适用于根元素或table-row元素常规流中的块级元素。

值属性

下表描述了此属性的值。

描述
auto如有必要,在元素之前插入一个分页符。这是默认值。
always始终在元素之前强制分页符。
avoid避免在元素之前分页。
left在元素之前强制分页一次或两个,以便下一页将成为左侧页面。
right在元素之前强制分页一次或两个,以便下一页将成为右侧页面。
initial将此属性设置为其默认值。
inherit如果指定,则关联元素采用其父元素page-break-值属性 before

兼容性浏览器

page-break-兼容性浏览器的before属性,下表中的数字表示支持该属性的浏览器最低版本号;所有主流浏览器均部分支持该属性。

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 4+

  • Apple Safari 1.2+

  • Opera 7+

警告: Internet Explorer 8和更早版本不支持这些值left和right; 任何一个值都被解释为值always。火狐,Chrome和Safari不支持的值avoid,left或right。

进一步阅读

请参考以下教程:Types Media CSS

属性相关:page-break-afterpage-break-inside