Solution for invalid background color when html page is printed

The situation I encountered was that after the introduction of the bootstrap framework, I wanted to print my own resume page, and found that the previously set styles and background colors became invalid. The reason for the problem was the default style of bootstrap.css.

@media print {
  *,
  *:before,
  *:after {
    color: #000 !important;
    text-shadow: none !important;
    background: transparent !important;
    -webkit-box-shadow: none !important;
            box-shadow: none !important;
  }中的

color: #000 !important;

background: transparent !important;

It is to set the font color to black and the background to transparent color, which makes your own style invalid. Just delete these two items in the source code, and there will be no problem with the printing style. Of course, you must download the resource. down to modify.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325521080&siteId=291194637