我希望讓客戶從網頁上打印漂亮的頁面。適合打印的網頁
因此,我改變從
<link rel="stylesheet" type="text/css" href="screen.css" media="screen"/>
下面一行
<link rel="stylesheet" type="text/css" href="print.css" media="print"/>
screen.css的含量和print.css是相同的。
但是,對於print
版本,我意識到我所有的CSS樣式都消失了。表格顏色,填充,邊距,字體...全部消失。當我在FireBug下查看時,似乎沒有任何風格。
我可以知道我錯過了什麼嗎?
print.html
<html>
<head>
<title>
</title>
<link rel="stylesheet" type="text/css" href="print.css" media="print"/>
</head>
<body>
<div>
<div class="main-title">Worksheet</div>
<div class="header-table-container">
<table>
<tbody>
<tr>
<th>House Address</th>
<td>33, Robinson Road.</td>
</tr>
<tbody>
</table>
</div>
<div class="main-table-container">
<table>
<tbody>
<tr>
<th width="10%" rowspan="2">Parts</th>
<th width="90%" colspan="4">Doraemon</th>
</tr>
<tr>
<th width="25%">Trial 1</th>
<th width="25%">Trial 2</th>
<th width="25%">Trial 3</th>
<th width="25%">Range</th>
</tr>
<tr>
<td class="numerical">1</td>
<td class="numerical">0.000</td>
<td class="numerical">0.000</td>
<td class="numerical">0.000</td>
<td class="numerical">0.000</td>
</tr>
</tbody></table>
</div>
<div class="main-table-container">
<table>
<tbody>
<tr>
<th width="10%" rowspan="2">Parts</th>
<th width="90%" colspan="4">Doraemon</th>
</tr>
<tr>
<th width="25%">Trial 1</th>
<th width="25%">Trial 2</th>
<th width="25%">Trial 3</th>
<th width="25%">Range</th>
</tr>
<tr>
<td class="numerical">1</td>
<td class="numerical">0.000</td>
<td class="numerical">0.000</td>
<td class="numerical">0.000</td>
<td class="numerical">0.000</td>
</tr>
</tbody></table>
</div>
<div class="main-table-container">
<table>
<tbody>
<tr>
<th width="10%" rowspan="2">Parts</th>
<th width="90%" colspan="4">Doraemon</th>
</tr>
<tr>
<th width="25%">Trial 1</th>
<th width="25%">Trial 2</th>
<th width="25%">Trial 3</th>
<th width="25%">Range</th>
</tr>
<tr>
<td class="numerical">1</td>
<td class="numerical">0.000</td>
<td class="numerical">0.000</td>
<td class="numerical">0.000</td>
<td class="numerical">0.000</td>
</tr>
</tbody></table>
</div>
</body>
</html>
print.css
body {
color:#000000;
font-family:Helvetica,Arial,sans-serif;
font-size:small;
}
table {
border:1px solid #BBBBBB;
border-collapse:collapse;
border-spacing:0;
clear:right;
margin:1em 0 0 1px;
font-size:small;
}
th {
background-color:#E5ECF9;
border:1px solid #BBBBBB;
font-weight:bold;
padding:3px 6px;
text-align:left;
}
td {
background-color:#FFFFFF;
border:1px solid #BBBBBB;
padding:3px 6px;
text-align:left;
vertical-align:top;
}
th.numerical,
td.numerical {
text-align:right;
}
.main-title {
text-align:center;
font-weight:bold;
font-size:large ;
}
.header-table-container {
}
.main-table-container {
float:left;
margin:0px 20px 0px 0px;
width:30%;
}
你進行打印測試?只是一個預感,也許Firebug不會顯示print.css,但是你的樣式實際上可能正在工作? – danjah 2010-11-08 04:02:44
你真的試過打印過嗎? 'media =「print」'意味着樣式將被用於* only *用於打印 - 不用於屏幕。 – 2010-11-08 04:04:24