我正在尝试打印页面。在该页面中,我为表格提供了背景色。当我在chrome中查看打印预览时,它不具有背景色属性…
所以我尝试了这个属性:
-webkit-print-color-adjust: exact;
但仍然没有显示颜色。
.vendorListHeading {
background-color: #1a4567;
color: white;
-webkit-print-color-adjust: exact;
}
<div class="bs-docs-example" id="soTable" style="padding-top: 10px;">
<table class="table" style="margin-bottom: 0px;">
<thead>
<tr class="vendorListHeading" style="">
<th>Date</th>
<th>PO Number</th>
<th>Term</th>
<th>Tax</th>
<th>Quote Number</th>
<th>Status</th>
<th>Account Mgr</th>
<th>Shipping Method</th>
<th>Shipping Account</th>
<th style="width: 184px;">QA</th>
<th id="referenceSO">Reference</th>
<th id="referenceSO" style="width: 146px;">End-User Name</th>
<th id="referenceSO" style="width: 118px;">End-User's PO</th>
<th id="referenceSO" style="width: 148px;">Tracking Number</th>
</tr>
</thead>
<tbody>
<tr class="">
<td>22</td>
<td>20130000</td>
<td>Jim B.</td>
<td>22</td>
<td>510 xxx yyyy</td>
<td>zznn@abc.co</td>
<td>PDF</td>
<td>12/23/2012</td>
<td>Approved</td>
<td>PDF</td>
<td id="referenceSO">12/23/2012</td>
<td id="referenceSO">Approved</td>
</tr>
</tbody>
</table>
</div>
Chrome CSS属性-webkit-print-color-adjust: exact;
可以正常工作。
但是,确保您拥有正确的CSS进行打印通常很棘手。可以做几件事来避免您遇到的困难。首先,将所有打印CSS与屏幕CSS分开。这是通过@media print
和完成的@media screen
。
通常,仅设置一些额外的@media print
CSS是不够的,因为在打印时您仍然包括所有其他CSS。在这些情况下,您只需要了解CSS的特殊性,因为打印规则不会自动与非打印CSS规则抗衡。
在您的情况下,-webkit-print-color-adjust: exact
可以正常工作。但是,您background- color
和颜色的定义已被其他具有更高特异性的CSS击败。
尽管我几乎在任何情况下 都 不赞成使用!important
,但以下定义可以正常工作并暴露问题:
@media print {
tr.vendorListHeading {
background-color: #1a4567 !important;
-webkit-print-color-adjust: exact;
}
}
@media print {
.vendorListHeading th {
color: white !important;
}
}
问题内容: 是否可以在Internet选项的“高级”选项卡中不启用“打印背景色和图像”的情况下打印背景图像? 我认为可以使用没有“背景图像”的替代方法…使用div标签和绝对位置可以模拟背景图像的相同效果吗?我也想在页面上重复背景图像。 问题答案: 打印背景图像(在标记中指定为背景图像的那些图像)的能力完全取决于最终用户,您无法从代码中以编程方式控制此功能。Firefox的一个插件提供了JavaSc
本文向大家介绍Bootstrap 3.x打印预览背景色与文字显示异常的解决,包括了Bootstrap 3.x打印预览背景色与文字显示异常的解决的使用技巧和注意事项,需要的朋友参考一下 我首先测试了一段如下的代码,发现打印预览时的确无法显示背景色。 比较奇怪的是,如果我删除bootstrap的样式引用,就可以正常打印预览了。想来必定是bootstrap3 设置了@media print相关属性导致。
问题内容: 我正在尝试使用chrome打印一个PHP生成的文档,在浏览器上看起来不错,链接到我要打印的页面,但是我的打印机无法打印任何彩色背景,请问有人可以提供任何建议吗?我可以用CSS做到这一点吗? 问题答案: 您可以在浏览器中调整是否打印背景颜色和图像。查看浏览器的打印选项。 GoogleChrome从26版(2013年3月)开始提供此功能。 同样从版本17开始,Chrome允许通过在元素CS
在超文本标记语言中,我什么时候使用颜色,背景颜色和背景标签有什么区别? 有什么区别?
background(int $color, int $pattern = self::PATTERN_SOLID): self int $color $format = new \Vtiful\Kernel\Format($fileHandle); $backgroundStyle = $format->background( \Vtiful\Kernel\Format::COLO
我正在制作一个基于文本的游戏,用户输入文本来解决游戏。我决定使用JavaSwing来显示文本,我希望文本窗格的背景为黑色。我已经尝试了所有我发现的东西(注释掉了),但是没有一个看起来有效。 这里没有显示导入的图片,但是当我使用任何被注释掉的部分运行游戏时,游戏中没有错误。