Print.js icon indicating copy to clipboard operation
Print.js copied to clipboard

background-color is ignored

Open LeaGoarant opened this issue 6 years ago • 4 comments

I am trying to use background-color in my CSS file using targetStyles: ['*'] for html to call it, but background-color is never applied. And when I change it to color, it works as intended.

LeaGoarant avatar Oct 07 '20 14:10 LeaGoarant

Hi @LeaGoarant, by default most browser's won't print the HTML background color. Try printing this very page and see how the browser ignores the grey background color from Github's top navigation bar. If you go into your browser settings, you should see an option to enable and disable this. Since this is a local user browser preference, we can't control it with Javascript alone.

crabbly avatar Oct 07 '20 14:10 crabbly

I had no idea about that ! Just want to add if other people cross this problem, that it can be easily fix by adding color-adjust:exact;.

LeaGoarant avatar Oct 07 '20 14:10 LeaGoarant

Awesome! I wasn't aware of this. Thanks for sharing, Lea.

For ref.: https://developer.mozilla.org/en-US/docs/Web/CSS/color-adjust

crabbly avatar Oct 07 '20 15:10 crabbly

I found that color-adjust: exact; doesn't work in chrome 89, while -webkit-print-color-adjust: exact; is effective. You can try adding a browser prefix.
1

jekorx avatar Mar 15 '21 03:03 jekorx