📜  CSS page-break-before 属性

📅  最后修改于: 2021-10-29 04:33:30             🧑  作者: Mango

CSS 中的 page-break-before 属性用于在指定元素之前添加一个分页符。

此属性有助于定义文档在打印时的行为方式。同样,page-break-before、page-break-after 和 page-break-inside 这三个属性都有助于确定并因此定义结果文档在打印时的方式。

注意: page-break-before 属性不能用于绝对定位的元素或空元素。

句法:

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

价值观

  • auto :指的是自动分页。
    page-break-before: auto;
    
     
     
     
         
            page-break-before: 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 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.      

                 Text credits :https://en.wikipedia.org/wiki/Paragraph                         
  • always:始终在指定元素框后插入分页符。
    page-break-before:always;
    
     
     
     
         
            page-break-before: always;
         
     
      
     
        

              The oldest classical Greek and Latin          writing had little or no space between         words and could be written in boustrophedon         (alternating directions).     

                 

              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.      

                 Text credits :https://en.wikipedia.org/wiki/Paragraph                         
  • 避免:尽可能避免分页。
    page-break-before:avoid;
    
     
     
     
         
            page-break-before: 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 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.      

                 Text credits :https://en.wikipedia.org/wiki/Paragraph                         
  • left:插入分页符,以便将下一页描绘为左页。
    page-break-before:left;
    
     
     
     
         
            page-break-before: 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 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.      

                 Text credits :https://en.wikipedia.org/wiki/Paragraph                         
  • 右:插入分页符,以便将下一页描绘为正确的页面。
    page-break-before:right;
    
     
     
     
         
            page-break-before: 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 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.      

                 Text credits :https://en.wikipedia.org/wiki/Paragraph                         
  • 初始:属性设置为默认值
    page-break-before:initial
    
     
     
     
         
            page-break-before: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 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.      

                 Text credits :https://en.wikipedia.org/wiki/Paragraph                         
  • 继承:属性从父元素继承
    page-break-before:inherit;
    
     
     
     
        css_page_break_before 
         
     
      
     
        

              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.     

          
              

              Indented paragraphs demonstrated in the US Constitution          In ancient manuscripts, another means to divide sentences          into paragraphs was a line break (newline) followed by an          initial at the beginning of the next paragraph. An initial          is an oversized capital letter, sometimes outdented beyond          the margin of the text. This style can be seen, for example,          in the original Old English manuscript of Beowulf.          

          
                 

              A second common modern English style is to use no indenting,          but add vertical white space to create "block paragraphs." On          a typewriter, a double carriage return produces a blank line          for this purpose; professional typesetters (or word processing          software) may put in an arbitrary vertical space by adjusting          leading.      

                 Text credits :https://en.wikipedia.org/wiki/Paragraph                

注意:通过选择给定 HTML 代码的网页的打印预览,可以最好地查看 page-break-before 属性的结果。在记事本++等文本编辑器上创建类似的代码,并选择对创建的网页进行打印预览。为了更好的理解,请尝试一下。

支持的浏览器: CSS page-break-before 属性支持的浏览器如下:

  • 谷歌浏览器
  • IE浏览器
  • 火狐
  • 歌剧
  • 苹果浏览器