Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css media type print using background-color in chrome

Tags:

I am using the background-color property in CSS media type print.

The problem is that Google Chrome does not show background-color or background-image in print preview.

How can this be solved?

like image 898
James Avatar asked Jan 07 '12 09:01

James


People also ask

What is the CSS code for background color?

Background-color values can be expressed in hexadecimal values such as #FFFFFF, #000000, and #FF0000. Background-color values can be expressed using rgb such as rgb(255,255,255), rgb(0,0,0), and rgb(255,0,0).

Why is my printer not printing the background color?

First on the File menu, click Options > on the Display menu, click to select the Print background colors and images check box under Printing Options > and then click OK. Hope above suggestion helps you and good luck! Was this reply helpful?


1 Answers

Chrome supports control of background colour / image printing via CSS. You can set the following CSS property on elements whose background should be printed:

-webkit-print-color-adjust: exact; 

Normally of course, this is determined by browser settings - but Chrome allows web designers to determine how backgrounds are printed on a per-element basis...

Notes:

  • Requires Chrome 17 or higher.
  • The background of the body tag is not printed.

Thanks to Cron’s Web Tech Blog, where I first spotted it:-

http://blog.crondesign.com/2011/11/print-css-backgrounds-in-google-chrome.html

Also, this leads to some background (no pun intended!) info regarding the feature:-

http://code.google.com/p/chromium/issues/detail?id=107763

Hope this helps...

like image 73
tranquil tarn Avatar answered Oct 24 '22 02:10

tranquil tarn