打印属性<o:p></o:p>
打印HTML文档总是会出现问题。在CSS2中,我们可以借助打印属性让打印web内容更容易一些。<o:p></o:p>
属性<o:p></o:p> | 描述<o:p></o:p> | 值<o:p></o:p> | W3C<o:p></o:p> |
orphans<o:p></o:p> | Sets the minimum number of lines for a paragraph that must be left at the bottom of a page<o:p></o:p> | number<o:p></o:p> | 2<o:p></o:p> |
marks<o:p></o:p> | Sets what sort of marks should be rendered outside the page box<o:p></o:p> | none crop cross<o:p></o:p> | <o:p></o:p> |
page<o:p></o:p> | Sets a page type to use when displaying an element<o:p></o:p> | auto identifier<o:p></o:p> | 2<o:p></o:p> |
page-break-after<o:p></o:p> | Sets the page-breaking behavior after an element<o:p></o:p> |
| 2<o:p></o:p> |
page-break-before<o:p></o:p> | Sets the page-breaking behavior before an element<o:p></o:p> |
| 2<o:p></o:p> |
page-break-inside<o:p></o:p> | Sets the page-breaking behavior inside an element<o:p></o:p> |
| 2<o:p></o:p> |
size<o:p></o:p> | Sets the orientation and size of a page<o:p></o:p> |
| <o:p></o:p> |
widows<o:p></o:p> | Sets the minimum number of lines for a paragraph that must be left at the top of a page<o:p></o:p> | number<o:p></o:p> | 2<o:p></o:p> |
<o:p> 当然除了上述办法以外,我们还可以通过控制设备类型,针对不同设备读取不同样式.</o:p>
Media Types 设备类型<o:p></o:p><o:p></o:p>
Media Type | CSS Version | Compatibility | Description |
all<o:p></o:p> | CSS2<o:p></o:p> | IE4+<o:p></o:p> | 用于所有设备类型<o:p></o:p> |
aural<o:p></o:p> | CSS2<o:p></o:p> | NONE<o:p></o:p> | 用于语音和音乐合成器 <o:p></o:p> |
braille<o:p></o:p> | CSS2<o:p></o:p> | NONE<o:p></o:p> | 用于触觉反馈设备<o:p></o:p> |
embossed<o:p></o:p> | CSS2<o:p></o:p> | NONE<o:p></o:p> | 用于凸点字符(盲文)印刷设备<o:p></o:p> |
handheld<o:p></o:p> | CSS2<o:p></o:p> | NONE<o:p></o:p> | 用于小型或手提设备 <o:p></o:p> |
print<o:p></o:p> | CSS2<o:p></o:p> | IE4+<o:p></o:p> | 用于打印机<o:p></o:p> |
projection<o:p></o:p> | CSS2<o:p></o:p> | NONE<o:p></o:p> | 用于投影图像,如幻灯片<o:p></o:p> |
screen<o:p></o:p> | CSS2<o:p></o:p> | IE4+<o:p></o:p> | 用于计算机显示器<o:p></o:p> |
tty<o:p></o:p> | CSS2<o:p></o:p> | NONE<o:p></o:p> | 用于使用固定间距字符格的设备。如电传打字机和终端<o:p></o:p> |
tv<o:p></o:p> | CSS2<o:p></o:p> | NONE<o:p></o:p> | 用于电视类设备 <o:p></o:p> |
<o:p> </o:p> | <o:p> </o:p> | <o:p> </o:p> | <o:p> </o:p> |
*注: 倘若是需要页面全部输出打印,则需要 将代码
- <link rel="stylesheet" type="text/css" media="screen,projection"
- href="css/aboutus.css" />
- <link rel="stylesheet" type="text/css" media="print" href="css/print.css" />
改为代码
- <link rel="stylesheet" type="text/css" media="all" href="css/aboutus.css" />
然后
进IE->工具->Internet选项->高级->打印 选中打印背景颜色和图片,这样就ok啦!