如何在所有浏览器的打印页面中获得跨浏览器兼容性? [英] How to get cross browser compatibility in Print on page from all browsers?
问题描述
如何在Print中获得跨浏览器兼容性?
How do you get cross browser compatibility in Print? any tips for print css file to make print on paper identical from all browser.
编辑
我已经在使用 Eric meyer CSS ,但是当我们从网站打印时,仍然面临不同浏览器的不一致。
I'm already using Eric meyer CSS but still facing inconsistencies in different browser when we take print from site.
与其他在 media = screen
我已经使用不同的CSS打印(print.css) media =print
I'm already using a different css for print (print.css) with media="print"
最好保持 * {posotion:static}
, * {float:none}
, * {clear:both}
in print css always?
Would it be better to keep * {posotion:static}
, *{float:none}
, * {clear:both}
in print css always?
推荐答案
相同的结果是不可能的。输出不仅取决于CSS,还取决于页边距,打印机功能,可用字体,纸张格式(A4与美国信函)以及可能有更多的单独设置。
Identical results are impossible. The output depends not only on CSS but also on individual settings for page margins, the printer’s capabilities, available fonts, paper format (A4 vs US Letter) and probably a lot more.
对于CSS
- 避免浮动和定位(相对,绝对和固定)。特别是Mozilla(Firefox)无法很好地处理这些属性。
- 使用
page-break - *
。某些浏览器甚至在图片中插入分页符。 - 您不知道页面宽度和高度(可以是A5)。保持一切尽可能灵活。
- 对于性能,将打印样式放入
@media print {}
规则中的主样式表中。 - 对于边框和边距,请使用
pt
而不是px
。打印机不知道像素是什么,可能会导致奇怪的结果。 - 在Opera中开发您的打印布局,它支持
@media print