Print style sheet, background color is ignored

I am creating a table in which I cyclically switch between every three odd and even classes. In my stylesheet, I have this:

  table tbody tr.odd {
     background-color: #cccccc;
 }

This works in the browser, but not when printing. Everything else in my multimedia style sheet works except for this background.

I have colors for printing, I can print images with colors ... right?

+3
source share
2 answers

By default, most browsers ignore background colors and CSS images when printing. This can only be undone by changing the settings in the browser, if the browser even has this capability (some do not, as Quentin points out).

+6
source

You can get the background color of the div in preview mode. The border color in divForBgColor:before will be the background color of the divForBgColor .

 .divForBgColor { position: relative; overflow: hidden; } .divForBgColor:before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border: 9999px solid #f1f2f2; z-index: -1; } 
0
source

Source: https://habr.com/ru/post/916048/


All Articles