我想加載它時打印頁面,我一直在嘗試打印@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