我有从我的网站打印报告的页面,我设置了显示网格结果的表格。
所以,我的问题是,我设置了 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;
让您的浏览器打印彩色背景...
值(value)观:
经济 正常行为。仅当用户在浏览器的打印设置对话框中明确允许时,才会打印背景颜色和图像。
准确 始终打印应用此规则的元素的背景颜色和图像,用户的打印设置将被覆盖。
希望对你有帮助
关于html - 打印页面时显示背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16256006/