📜  CSS page-break-after属性

📅  最后修改于: 2020-11-05 04:32:30             🧑  作者: Mango

CSS page-break-after此CSS属性用于在打印文档时调整元素后的分页符。在打印过程中,它将在指定元素之后插入一个分页符。我们不能在绝对定位的元素(position:absolute;)或空元素上使用此属性

不生成框的元素。

此CSS属性表示在元素框后是否允许分页符。 CSS属性page-break-before和page-break-inside包括page-break-after,可帮助我们定义打印时文档的行为。

句法

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

属性值

此CSS属性的值的简要说明列表如下。

Values Description
auto It is the default value that inserts a page break after the element, if necessary.
Always It always forces a page break after the specified element.
avoid It is used to avoid a page break after the element whenever possible.
left It forces either one or two page breaks after the specified element so that the next page will be depicted as the left-hand page.
right It forces either one or two page breaks after the specified element so that the next page will be depicted as the right-hand page.
Initial It sets the property to its default value.
Inherit If this value is specified, the corresponding element uses the computed value of its parent element.

让我们使用每个示例来了解上述值。

示例-使用自动值

值auto是默认值,可在需要时自动插入分页符。在这个例子中,我们使用两个

元素和一个按钮。该按钮负责print页面。单击按钮后,我们将看到该值的效果。


    
      
   
   
      

Hello World!!

Welcome to the javaTpoint.com.

This site is developed so that students may learn computer science related technologies easily. The javaTpoint.com is committed to providing easy and in-depth tutorials on various technologies. No one is perfect in this world, and nothing is eternally best. But we can try to be better.

输出量

示例-使用Always值

无论是否需要,此值始终强制插入分页符。我们正在使用一个按钮来打印页面。我们必须单击该按钮才能看到效果。


    
      
   
   
      

Hello World!!

Welcome to the javaTpoint.com.

This site is developed so that students may learn computer science related technologies easily. The javaTpoint.com is committed to providing easy and in-depth tutorials on various technologies. No one is perfect in this world, and nothing is eternally best. But we can try to be better.

输出量

示例-使用左值

左值强制插入一个或两个分页符,以便下一页的格式将为左页。


    
      
   
   
      

Hello World!!

Welcome to the javaTpoint.com.

This site is developed so that students may learn computer science related technologies easily. The javaTpoint.com is committed to providing easy and in-depth tutorials on various technologies. No one is perfect in this world, and nothing is eternally best. But we can try to be better.

输出量

示例-使用正确的值

right值将强制插入一个或两个分页符,以便将下一页的格式设置为正确的页面。


    
      
   
   
      

Hello World!!

Welcome to the javaTpoint.com.

This site is developed so that students may learn computer science related technologies easily. The javaTpoint.com is committed to providing easy and in-depth tutorials on various technologies. No one is perfect in this world, and nothing is eternally best. But we can try to be better.

输出量