问题
Here I've a table with embedded sub-tables. I've been looking now for a couple of hours, but didn't found the reason for the problem. The problem is, that some of the columns in the main table have fixed width via css style and only Firefox cares about that. IE8 in standard mode displays the fixed cols a bit to wide and in compatibility mode it's worst. Here's a code snippet:
<table>
<thead><tr>
<th style="width:80px;"><div style="float: right;" class="links"><a href="/link?s=object_id-asc" title="Aufsteigend sortieren"><span class="imgarrupactive"> </span></a><a href="/link?s=object_id-desc" title="Absteigend sortieren"><span class="imgarrdown"> </span></a></div>Objekt-ID</th>
<th style="width:50px;"><div style="float: right;" class="links"><a href="/link?s=zipcode-asc" title="Aufsteigend sortieren"><span class="imgarrup"> </span></a><a href="/link?s=zipcode-desc" title="Absteigend sortieren"><span class="imgarrdown"> </span></a></div>PLZ</th>
<th><div style="float: right;" class="links"><a href="/link?s=city-asc" title="Aufsteigend sortieren"><span class="imgarrup"> </span></a><a href="/link?s=city-desc" title="Absteigend sortieren"><span class="imgarrdown"> </span></a></div>Ort</th>
<th><div style="float: right;" class="links"><a href="/link?s=street-asc" title="Aufsteigend sortieren"><span class="imgarrup"> </span></a><a href="/link?s=street-desc" title="Absteigend sortieren"><span class="imgarrdown"> </span></a></div>Straße</th>
<th style="width:60px;"><div style="float: right;" class="links"><a href="/link?s=number-asc" title="Aufsteigend sortieren"><span class="imgarrup"> </span></a><a href="/link?s=number-desc" title="Absteigend sortieren"><span class="imgarrdown"> </span></a></div>HNR</th>
<th style="width:57px;">Aktion</th>
</tr></thead>
<tbody>
<tr class="tr_color_switch"><td style="text-align:center;">000</td><td style="text-align:center;">111</td><td>222</td><td>333</td><td>444</td><td><div class="link" onclick="contactHistoryPrint(this,'ab 01.09.2010');" title="Druckversion"><span class="imgtext"> </span></div></td></tr>
<tr class="tr_color_switch"><td colspan="6" style="padding: 0;">
<table class="subtable">
<thead><tr><th style="width:80px;">Selektionsdatum</th><th style="width:80px;">Versanddatum</th><th style="width:400px;">Aktion</th></tr></thead>
<tbody>
<tr><td colspan="3"><i>keine Daten vorhanden</i></td></tr>
</tbody>
</table>
<div class="clear"></div>
</td></tr>
<tr class="tr_color_switch"><td style="text-align:center;">aaa</td><td style="text-align:center;">bbb</td><td>ccc</td><td>ddd</td><td>eee</td><td><div class="link" onclick="contactHistoryPrint(this,'ab 01.09.2010');" title="Druckversion"><span class="imgtext"> </span></div></td></tr>
<tr class="tr_color_switch"><td colspan="6" style="padding: 0;">
<table class="subtable">
<thead><tr><th style="width:80px;">Selektionsdatum</th><th style="width:80px;">Versanddatum</th><th style="width:400px;">Aktion</th></tr></thead>
<tbody>
<tr><td colspan="3"><i>keine Daten vorhanden</i></td></tr>
</tbody>
</table>
<div class="clear"></div>
</td></tr>
[...]
When I reduce the width of the third column in the sub tables from 400px to 100px or less, all is fine, but that's not my intention. Here are some screenshots how this table is displayed:
LINK
Document type is:
<!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">
Can anyone help?
回答1:
Funny, my second question here and found the solution on my own :) Adding css "table-layout: fixed;" to the main table did the trick!
Internet Explorer 8 table cell width bug with colspan set
来源:https://stackoverflow.com/questions/5216591/broken-table-layout-in-ie8-with-embedded-tables-within-another-table