page-break-before和page-break-after 实现分页打印
2017-11-30 17:31
337 查看
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属性会将分页符号加在指定组件后,而非之前。在下列
程序中您将可以看到这些属性的设定:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</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>
转载地址:http://blog.163.com/fan_yishan/blog/static/4769221320091043619358/
程序中您将可以看到这些属性的设定:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</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>
可用值
值 | 描述 |
---|---|
auto | Insert a page break after the element if necessary 假如需要在对象之后插入页分割符 |
always | Insert a page break after the element 始终在对象之后插入页分割符 |
avoid | Avoid inserting a page break after the element 避免在对象后面插入页分割符 |
left | Insert page breaks after the element until it reaches a blank left page 在对象后面插入页分割符直到它到达一个空白的左页边 |
right | Insert page breaks after the element until it reaches a blank right page 在对象后面插入页分割符直到它到达一个空白的右页边 |
相关文章推荐
- 应用CSS的page-break-after属性 实现WEB页面强制分页打印
- 打印分页css样式:<div style='page-break-after: always;'></div>
- 谷歌浏览 打印无法分页 page-break-after: always
- web 打印分页page-break-after
- 打印分页css样式,style="page-break-after:always;"
- 分页打印 PAGE-BREAK-AFTER: always
- div+css - page-break-before设置打印分布符
- page-break-before和page-break-after[转]
- page-break-before和page-break-after
- page-break-after多打印一页问题的解决
- 控制网页的分页 page-break-after
- 在 SSM 中基于 MyBatis-PageHelper 分页插件的分页功能实现
- 巧妙利用before和after伪类实现文字的展开和收起
- asp.net中使用repeater和PageDataSource搭配实现分页代码
- jsp调用IE打印控件实现打印功能,并且实现分页功能
- SSM框架下分页的实现(封装page.java和List<?>)
- asp.net 实现在线打印功能,jQuery打印插件PrintArea实现自动分页
- 用pageGroup.js实现分页功能
- PageBean方式实现分页效果 泽0715
- 数据分页模块系列 完美封装PageModel实现分页模块