如何在所有浏览器的打印页面中获得跨浏览器兼容性? [英] How to get cross browser compatibility in Print on page from all browsers?

查看:206
本文介绍了如何在所有浏览器的打印页面中获得跨浏览器兼容性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在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 如果您使用保留ID

  • 不要依赖打印预览。你在真正的打印输出上得到非常不同的结果。用一个打印到pdf驱动程序保存雨林。 :)

  • Avoid floats and positioning (relative, absolute and fixed). Especially Mozilla (Firefox) can not handle those properties very well.
  • Use page-break-* but don’t rely on it. Some browsers insert page breaks even in images.
  • You don’t know the page width and height (could A5). Keep anything as flexible as possible.
  • For performance, put your print style into the main stylesheet in a @media print {} rule.
  • Use pt not px for borders and margins. A printer doesn’t know what a pixel is and may come to strange results.
  • Develop your print layout in Opera, which has the best support for @media print currently, and insert compatibility hacks, when you’re done.
  • Internet Explorer may crash on print, if you use its reserved IDs.
  • Never rely on print preview. You get very different results on real printouts. Save the rain forest with a print-to-pdf-driver. :)

这篇关于如何在所有浏览器的打印页面中获得跨浏览器兼容性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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