【发布时间】:2010-08-12 16:09:44
【问题描述】:
下面是一个测试 HTML 文件。它在屏幕上显示正常,但是当我在 Firefox 3.6.8 或 IE 7.0 中“打印”或“打印预览”时,表格边框不会出现。我错过了什么?
<html>
<head>
<style type="text/css">
body {
background: black;
font-family: arial, sans-serif;
color: white;
}
table.param, table.param td, table.param th {border: 1px solid white; border-collapse: collapse; }
table.param td { text-align: left; vertical-align: bottom; color: white; font-size: 90%; }
h2,h3 { margin: 0; }
a:link { color: #00FF00; }
a:visited { color: #8080FF; }
a:hover { color: #FFFFFF; }
a:active { color: #FFFF00; }
</style>
</head>
<body><h2>Software Parameters</h2>
<table class="param"><tbody>
<tr><th>head1</th><th colspan="3">blah blah blah</th></tr>
<tr><td>param1</td><td>foo</td><td>2000</td><td>param1 description</td></tr>
<tr><td>param2</td><td>bar</td><td>4000</td><td>param2 description</td></tr>
<tr><td>param3</td><td>baz</td><td>3000</td><td>param3 description</td></tr>
</tbody></table>
</body>
</html>
更新:啊哈,看起来像 <style> tag has a media attribute。我改编了 Derek 的答案,现在我让它在 IE 7.0 但不是 Firefox 3.6.8 中工作:(这是 Firefox 中的一个已知错误吗?)
<html>
<head>
<style type="text/css" media="print">
body {
background: white;
color: black;
}
</style>
<style type="text/css" media="screen">
body {
background: black;
color: white;
}
</style>
<style type="text/css">
body {
font-family: arial, sans-serif;
}
table.param, table.param td, table.param th {border: 1px solid; border-collapse: collapse; }
table.param td { text-align: left; vertical-align: bottom; font-size: 90%; }
h2,h3 { margin: 0; }
a:link { color: #00FF00; }
a:visited { color: #8080FF; }
a:hover { color: #FFFFFF; }
a:active { color: #FFFF00; }
</style>
</head>
<body><h2>Software Parameters</h2>
<table class="param"><tbody>
<tr><th>head1</th><th colspan="3">blah blah blah</th></tr>
<tr><td>param1</td><td>foo</td><td>2000</td><td>param1 description</td></tr>
<tr><td>param2</td><td>bar</td><td>4000</td><td>param2 description</td></tr>
<tr><td>param3</td><td>baz</td><td>3000</td><td>param3 description</td></tr>
</tbody></table>
</body>
</html>
【问题讨论】: