Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
986 views
in Technique[技术] by (71.8m points)

css - How to get cross browser compatibility in Print on page from all browsers?

How do you get cross browser compatibility in Print? any tips for print css file to make print on paper identical from all browser.

Edit

I'm already using Eric meyer CSS but still facing inconsistencies in different browser when we take print from site.

Is there any CSS declarations which we can use always and put at a top in print css , Like other css resets which work good in media=screen?

I'm already using a different css for print (print.css) with media="print"


Would it be better to keep * {posotion:static} , *{float:none} , * {clear:both} in print css always?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

For CSS

  • 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. :)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...