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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。