我想加载它时打印页面,我一直在尝试打印@media print
页面CSS
,但我不能让它工作,无论我做什么。HTML - 打印页面不检索CSS
我唯一需要做的就是在<th>
标签中应用颜色。
HTML代码:
<body onload="window.print();">
<div>
<h2 class="text-center"><span class="label label-default">Order Form Details</span></h2><br>
<table class="table table-hover table-responsive">
<thead>
<tr>
<th>Name</th>
<th>Surname</th>
<th>Telephone</th>
<th>Postal Code</th>
<th>Priority</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
</body>
CSS代码:
th {
background-color: #C8C8C8;
}
的jsfiddle here
是啊,已经试过这个,在'@media print'中加入'!important',但没有,没有解决它 –
加上它的'@media print',而不是'@media print()'我认为 –
打印背景颜色可能会受到浏览器设置的影响。请查看[https://stackoverflow.com/questions/3893986/css-media-print-issues-with-background-color](https://stackoverflow.com/questions/3893986/css-media-print-issues- with-background-color) – jfeferman