我希望每个打印页面都重复我的表格标题,但似乎谷歌Chrome不能<thead>很好地支持标签......有没有办法解决这个问题?我正在使用Google Chrome v13.0.782.215.
表格代码非常简单......没什么特别的:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css" media="all">
@page {
size: landscape;
margin-top: 0;
margin-bottom: 1cm;
margin-left: 0;
margin-right: 0;
}
table {
border: .02em solid #666; border-collapse:collapse;
width:100%;
}
td, th {
border: .02em solid #666; font-size:12px; line-height: 12px;
vertical-align:middle; padding:5px; font-family:"Arial";
}
th { text-align:left; font-size:12px; font-weight:bold; }
h2 { margin-bottom: 0; }
</style>
</head>
<body>
<h2>Page Title</h2>
<table>
<thead>
<tr class="row1">
<th><strong>Heading 1</strong></th>
<th><strong>Heading 2</strong></th> …Run Code Online (Sandbox Code Playgroud) 我需要在Internet Explorer(各种版本)和OS X上的Safari中打印HTML表格中的一些数据.暂时忽略Safari.
当打印的行数超过页面上可以容纳的行时,页面上的最后一行通常会与第一页上的行的一部分以及下一页上的行的其余部分分开.
这看起来很难看.有没有办法避免它?
我一直在寻找,到目前为止我找到了page-break-before: always,但我不确定这是否是我正在寻找的,因为我不知道前面有多少行适合页面.例如,根据内容,行可能更高或更短,并且用户可能以纵向或横向模式打印.我至少假设A4,但如果用户使用的是美国信或其他纸张尺寸,则会引入更多的不确定性.另外,打印机边距怎么样?
那么有办法解决这个问题吗?或者我只需要猜测适合多少行并在此之后强制分页?这甚至会起作用吗?