page-break-before Attribute

page-break-before Attribute | pageBreakBefore Property

Sets or retrieves a string indicating whether a page break occurs before the object.

Syntax

HTML

{ page-break-before : sBreak }

Scripting

[ sBreak = ] object.style.pageBreakBefore

Possible Values

sBreak

String that specifies or receives one of the following values.

always

Always insert a page break before the object.

总是在对象前面分页

auto

Default. Neither force nor forbid a page break before the object.

默认。既不强制也不禁止在对象前面分页

avoid

Internet Explorer 8. Forbid a page break before the object, if possible.

IE8中禁止在对象前面分页

empty string

Behaves the same as auto.

auto属性相同

inherit

Internet Explorer 8. Inherit the value of the same property for the object's parent.

left

Currently behaves the same as always.

right

Currently behaves the same as always.

The property is read/write for all objects except the following, for which it is read-only: currentStyle. The property has a default value of auto. The Cascading Style Sheets (CSS) attribute is not inherited.

DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are not supported in IE8 mode. For more information, see About Dynamic Properties.

Remarks

This property applies when printing the document. This property does not apply to the BR or HR elements.

If there are conflicts between the value of this property and the pageBreakAfter property of the object previously displayed in the browser, the value that results in the largest number of page breaks is used.

Page breaks are not permitted inside positioned objects.

Examples

The following examples use the page-break-before attribute and the pageBreakBefore property to start printing on a new page.

This example uses the H3 element as a selector in an embedded style sheet to break the page before all H3 headings.

Copy Code

<html>

 

<head>

<style type="text/css">

h3 {

        page-break-before: always;

}

</style>

</head>

 

<body>

 

<p>

:

</p>

<h3>Start New Section on New Page</h3>

 

</body>

 

</html>

This example uses a button to turn off the page break before the object that has an ID value of oPrgrph. When the page is printed or previewed, a page break occurs before the first paragraph unless the user clicks the button.

Copy Code

<html>

 

<head>

<script type="text/javascript">

function offBreak()

{

    oPrgrph.style.pageBreakBefore="";

}

</script>

</head>

 

<body>

 

<button οnclick="offBreak()">Turn Off Break</button>

<p id="oPrgrph" style="page-break-before: always">

:

</p>

 

</body>

 

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值