css打印样式 [英] css print styling

查看:188
本文介绍了css打印样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,在屏幕上显示精致。



我有一个css,然后格式化屏幕打印和重新调整部分。 >

我的问题是,打印布局从页面左边有一个大约一英寸的边缘,使得2个元素从页面右侧打印。



我可以压缩右边的内容,但我想知道是否可以减少左边的边距(并且基本上是内容的中心)



我已将body上的body标签设置为 margin:0; padding:0;

解决方案



是否有其他设置控制打印边距? >

您可以使用CSS设置打印边距(和横向):

  @media print {
@page {
size:letter landscape;
margin:4.0cm;
}
}


好消息是! (在Chrome上。在其他浏览器上不支持,但我没有测试IE9。)



页边距必须是在打印时有意义的单位,不允许使用像素。



Chrome不会缩小页边距低于固定的最小值,这可以由打印机驱动程序确定。


I have a page which displays fine on the screen.

I have a css which then formats the screen for print and re-sizes the sections.

My problem is that the print layout has a margin of approximately an inch from the left of the page which makes 2 elements print off the page on the right hand side.

I could probably compress the contents from the right but I want to know if I can reduce the margin on the left (and basically center the contents)

I have set the body tag on print to margin:0; padding: 0; but this has no effect?

Is there another setting that controls print margins?

解决方案

You can set the print margin (and landscape orientation) with CSS like:

@media print {
    @page {
        size: letter landscape;
        margin: 4.0cm;
    }
}


And the good news is, it works! (On Chrome. Not supported on other browsers though I did not test IE9.)

The margin must be in a unit that makes sense in print -- pixels are not allowed.

Chrome will not shrink the margin below a fixed minimum, which may be determined by the printer driver.

这篇关于css打印样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆