CSS中的page-break-after属性用于在指定的元素之后添加page-break。
同样,page-break-before,page-break-after和page-break-inside这三个属性都有助于确定并定义如何打印结果文档。
注意:page-break-after属性不能用于绝对定位的元素或空的<div>元素。
用法:
page-break-after:auto|always|avoid|left|right|initial|inherit;
属性值:
- auto:此值是指自动page-break。
page-break-after:auto;
例:
<!DOCTYPE html> <html> <head> <title> page-break-after:auto </title> </head> <body> <p style= "page-break-after:auto;"> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> Text credits:https://en.wikipedia.org/wiki/Paragraph </body> </html>
- always:使用此值时,总是在指定的元素框后插入分页符。
page-break-after:always;
例:
<!DOCTYPE html> <html> <head> <title> page-break-after:always </title> </head> <body> <p style= "page-break-after:always;"> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> <p style= "page-break-after:always;"> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> Text credits:https://en.wikipedia.org/wiki/Paragraph </body> </html>
- avoid:使用此值时,将尽可能避免分页符。
page-break-after:avoid;
例:
<!DOCTYPE html> <html> <head> <title> page-break-after:avoid </title> </head> <body> <p style= "page-break-after:avoid;"> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> <p> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> Text credits:https://en.wikipedia.org/wiki/Paragraph </body> </html>
- left:使用此值时,将插入分页符,以便将下一页描绘为左页。
page-break-after:left;
例:
<!DOCTYPE html> <html> <head> <title> page-break-after:left </title> </head> <body> <p style= "page-break-after:left;"> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> <p> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> Text credits:https://en.wikipedia.org/wiki/Paragraph </body> </html>
- right:使用此值时,将插入分页符,以便将下一页描绘为左页。
page-break-after:right;
例:
<!DOCTYPE html> <html> <head> <title> page-break-after:right </title> </head> <body> <p style= "page-break-after:right;"> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> <p> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> Text credits:https://en.wikipedia.org/wiki/Paragraph </body> </html>
- initial:如果使用此值,则该属性将设置为默认值。
page-break-after:initial;
例:
<!DOCTYPE html> <html> <head> <title> page-break-after:initial </title> </head> <body> <p style= "page-break-after:initial;"> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> <p> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> Text credits:https://en.wikipedia.org/wiki/Paragraph </body> </html>
- inherit:属性是从父元素继承的
page-break-after:inherit;
例:
<!DOCTYPE html> <html> <head> <title>css_page_break_after</title> <style> p { page-break-after:always; } div{ page-break-after:default; } #c1{ page-break-after:left; } #c2{ page-break-after:inherit; } </style> </head> <body> <p> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> <div> <p id="c2"> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </div> <p id="c1"> The oldest classical Greek and Latin writing had little or no space between words and could be written in boustrophedon (alternating directions). Over time, text direction (left to right) became standardized, and word dividers and terminal punctuation became common. The first way to divide sentences into groups was the original paragraphos, similar to an underscore at the beginning of the new group.[2] The Greek paragraphos evolved into the pilcrow, which in English manuscripts in the Middle Ages can be seen inserted inline between sentences. The hedera leaf (e.g. ?) has also been used in the same way. </p> Text credits:https://en.wikipedia.org/wiki/Paragraph </body> </html>
注意:通过选择给定HTML代码的网页的打印预览,可以最佳地查看page-break-after属性的结果。在文本编辑器(如notepad ++)上创建类似的代码,然后选择对创建的网页进行打印预览。请尝试以更好地理解它。
支持的浏览器:下面列出了page-break-after属性支持的浏览器:
- 谷歌浏览器
- IE浏览器
- 火狐浏览器
- Opera
- 苹果浏览器
相关用法
- HTML Style pageBreakAfter用法及代码示例
- CSS transition-property用法及代码示例
- CSS all属性用法及代码示例
- CSS top属性用法及代码示例
- CSS nav-right用法及代码示例
- CSS right属性用法及代码示例
- CSS nav-up用法及代码示例
- CSS nav-down用法及代码示例
- HTML DOMRectReadOnly y用法及代码示例
- CSS shape-outside用法及代码示例
- CSS transform属性用法及代码示例
- CSS left属性用法及代码示例
- CSS perspective属性用法及代码示例
- HTML DOMRect right用法及代码示例
- HTML DOMRect top用法及代码示例
注:本文由纯净天空筛选整理自EnaMotwani大神的英文原创作品 CSS | page-break-after Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。