posts - 710,  comments - 81,  views - 260万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

样式:

<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”值再加以控制一般的问题都能解决,以下为例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<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>

  


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<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   itprobie-菜鸟程序员  阅读(13166)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示