zoukankan      html  css  js  c++  java
  • css控制页面打印(分页、屏蔽不需要打印的对象)

    样式:

    <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>
    

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

  • 相关阅读:
    PHP学习笔记:APACHE配置虚拟目录、一个站点使用多域名配置方式
    转载:分页原理+分页代码+分页类制作
    PHP学习笔记:数据库学习心得
    PHP学习笔记:用mysqli连接数据库
    PHP学习笔记:MySQL数据库的操纵
    PHP学习笔记:利用时间和mt_rand函数获取随机名字
    PHP学习笔记:等比例缩放图片
    前端学习(一) html介绍和head标签
    Python 协程
    Python 线程----线程方法,线程事件,线程队列,线程池,GIL锁,协程,Greenlet
  • 原文地址:https://www.cnblogs.com/guohu/p/5748955.html
Copyright © 2011-2022 走看看