HTML / CSS - 为什么背景颜色在打印时变成白色? [英] HTML/CSS - Why background-color turns white when printing?

查看:142
本文介绍了HTML / CSS - 为什么背景颜色在打印时变成白色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的背景颜色甚至我的元素的字体颜色在打印时突然变白。以下是一个示例标记:

My background color or even the font colors of my elements suddenly turns white when printing. Here's a sample markup:

<div id="ActionPanel">
    <input type="button" onclick="javascript:window.print();" value="Print"> 
</div>

<p id="P1">
   Hello World! 
</p>

<p id="P2">
   Hello Web! 
</p>

<p id="P3">
   Hello StackOverflow 
</p>

一个这里的CSS

@media all 
{
   body
   {
       background-color:green;
   }

   #P1
   {
       background-color:#f00;    
   } 
}

@media print 
{
   #ActionPanel
   {
       visibility:hidden;
   } 
}


推荐答案

背景将自动从打印版本中删除。这是防止墨水浪费的方法。

All backgrounds are automatically stripped away from the printed version. It is that way to prevent ink waste.

但您可以在浏览器中启用它。 (具体如何做取决于每个浏览器)。

You can however, enable it in your browser. (How to do that depends on each browser specifically).

这篇关于HTML / CSS - 为什么背景颜色在打印时变成白色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆