js window.print() 打印TD背景色,客户需要在打印的label固定文字增加浅灰色背景色,页面样式调整如下:
全局CSS样式设置如下:
@media print {
body {
-webkit-print-color-adjust:exact;
-moz-print-color-adjust:exact;
-ms-print-color-adjust:exact;
print-color-adjust:exact;
}
}
TD元素 的样式background-color属性增加 !important
<tr>
<td height="15px" width="15%" colspan="2" align="center" style="background-color:#e0e0e0 !important"><strong>公司名称</strong></td>
<td colspan="3" width="35%" th:text="*{comName}"></td>
<td colspan="2" width="15%" align="center" style="background-color:#e0e0e0 !important"><strong>项目名称</strong></td>
<td colspan="2" width="35%" th:text="*{projectName}"></td>
</tr>