样式:

<style   media="print">   
  .Noprint   {   DISPLAY:   none;}   
  .PageNext   {   PAGE-BREAK-AFTER:   always   }   
</style>  

注:

①、不需要打印的对象要用上“Noprint”样式。

②、需要换页处理的对象要用上“PageNext”样式。

③、因为最后一页不用加入换页符,所以要控制最后一页不要使用该样式。个人感觉用PAGE-BREAK-BEFORE属性控制第一页要方便一些。

=====================================================================================

page-break-before和page-break-after(来自网络)

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属性会将分页符号加在指定组件后,而非之前。

设置为left或right 与 设置为alvays究竟有什么区别,上面红色字体的说明看不明白,希望看到贴字的明白人指点一二。

不过用“always”值再加以控制一般的问题都能解决,以下为例子:

<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-before: always">
        This is the third DIV.</div>
    <div style="page-break-before: always">
        This is the fourth DIV.</div>
</body>
</html>

  


<html>
<head>
    <title>Listing 14-4</title>
</head>
<body>
    <div style="page-break-after: always">
        This is the first DIV.</div>
    <div style="page-break-after: 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>
</body>
</html>

  程序员的基础教程:菜鸟程序员

posted on 2016-08-08 13:29  itprobie-菜鸟程序员  阅读(12934)  评论(0编辑  收藏  举报