page-break-before和page-break-after css属性并不会修改网页在屏幕上的显示,这两个属性是用来控制文件的打印方式。每个打印属性都可以设定4种设定值:auto、always、left和right。其中auto是默认值,只有在有需要时,才需设定分页符号 (page breaks)。page-break-before若设定成always,则是在遇到特定的组件时,打印机会重新开始一个新的打印页。page-break-before若设定成left,则会插入分页符号,直到指定的组件出现在一个左边的空白页上。page-break-before若设定成right,则会插入分页符号,直到指定的组件出现在一个右边的空白页上。page-break-after属性会将分页符号加在指定组件后,而非之前。在下列
程序中您将可以看到这些属性的设定,
<html>
<head>
<title>listing 14-4</title>
</head>
<body>
<div>this is the first div.</div>
<div style="page-break-before:always">this is the second div.</div>
<div style="page-break-after:always">this is the third div.</div>
<div>this is the fourth div.</div>
<div style="page-break-before:right">this is the fifth div.</div>
<div style="page-break-after:right">this is the sixth div.</div>
<div>this is the last div.</div>
</body>
</html>
可用值
以上就是css中page-break-before与page-break-after实现分页打印详解的详细内容。