在不勾选“打印背景颜色和图像”的情况下在 IE 中打印背景图像和颜色

Print background images and colors in IE without checking “Print background colors and images”

我添加了 media="print" 样式表,我添加了 *{-webkit-print-color-adjust: exact;} 但只有 chrome 显示背景(图像和颜色)!有没有不勾选“打印背景颜色和图像”的解决方案?

As noted on MDN

This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

因此不应该依赖它,确实 Chrome 中的支持标记为 'Buggy',所有其他浏览器 不支持 支持,注意-webkit-供应商前缀的使用表示打算在webkit浏览器中'support',IE不使用webkit引擎。

通常,您无法确定/覆盖/编码打印背景颜色和图像的选项。一种方法是利用其他属性/元素,例如对实际图像使用 img 元素,或者使用具有极宽边框的伪元素来模仿背景颜色。然而,通常两者都不实用。

不幸的是,跨浏览器对打印或分页媒体模块的支持也很糟糕。事实上,CSS 工作组有一个 large discussion around the whole topic