我有从我的网站打印报告的页面,并且为显示网格结果设置了表格。
所以,我的问题是,我设置了th
属性表的背景色,该背景在打印之前显示在页面上,但是在打印时,th
背景却不显示。
这是我的CSS代码:-
@media print {
.head th {
background: #CCCCCC;
background: -webkit-gradient(linear, left top, left bottom, from(#CCCCCC), to(#CCCCCC));
background: -moz-linear-gradient(top, #CCCCCC, #CCCCCC);
border: 1px solid #000000;
font-size: 16px;
text-align: center;
font-weight:bold;
padding:10px;
}
}
.wrap{
width: auto;
background:#fff;
word-wrap: break-word;
margin:30px;
}
th {
background: #CCCCCC;
background: -webkit-gradient(linear, left top, left bottom, from(#CCCCCC), to(#CCCCCC));
background: -moz-linear-gradient(top, #CCCCCC, #CCCCCC);
border: 1px solid #000000;
font-size: 16px;
text-align: center;
font-weight:bold;
padding:10px;
}
打印此页面时如何显示
th
背景。 最佳答案
尝试看看-webkit-print-color-adjust:exact;
以使您的浏览器可以打印彩色背景...
评估:
经济
正常行为。仅当用户在浏览器的“打印设置”对话框中明确允许背景颜色和图像时,才打印背景颜色和图像。
精确
应用此规则的元素的背景色和图像始终会被打印,而用户的打印设置将被覆盖。
希望这可以帮助