Paul O'B,
I figured out why my example code wasn't working...
There are two reasons, actually. First, the inline-block div needs to have content. For some reason, both FF and IE will add a small bottom margin to an inline-block element if it has nothing in it, which was preventing the div from aligning perfectly with the table. Putting a <br /> or an inside the inline-block div will fix this problem.
Second, the formula for calculating the height of the inline-block div and the negative margin needs to have the height of the footer added to it. This will prevent any weird overlapping footer issues.
Here is a revised example that should work perfectly in both FF and IE (as before, the spacer div will probably have to be enlarged to make the table overflow your A4 paper
):
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
line-height: 18px;
font-size: 14px;
}
table {
width: 700px;
margin: 0 auto 0 auto;
table-layout: fixed;
border-spacing: 0;
}
th, td {
padding: 0;
border: solid black;
border-width: 0 1px 1px 0;
}
th:first-child, td:first-child {
border-left-width: 1px;
}
th {
border-top-width: 1px;
}
</style>
</head>
<body>
<div style="height: 900px;">
<!--resize this div to change page break location-->
</div>
<div style="display: inline-block; height: 58px;">
<br />
</div>
<div style="margin-bottom: -58px;">
</div>
<table>
<thead>
<tr>
<th>
Header
</th>
<th>
Header
</th>
</tr>
</thead>
<tfoot>
<tr>
<td>
Footer
</td>
<td>
Footer
</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>
Data
</td>
<td>
Data
</td>
</tr>
<tr>
<td>
Data
</td>
<td>
Data
</td>
</tr>
<tr>
<td>
Data
</td>
<td>
Data
</td>
</tr>
</tbody>
</table>
</body>
</html>
Bookmarks