【发布时间】:2011-05-25 10:31:30
【问题描述】:
将table-layout:fixed 应用于表格并在单元格上使用填充时,我得到了不同的结果。通过将单元格宽度和内边距相加,IE 和 Firefox 似乎可以正常工作。 Chrome 和 Safari 仅使用单元格宽度。我看到这个问题有一个错误,但找不到任何解决方法。有谁知道如何绕过它?
WebKit Bugzilla:https://bugs.webkit.org/show_bug.cgi?id=13339
table {
width:200px;
border-collapse:collapse;
}
#table-1 {
table-layout:auto;
}
#table-2 {
table-layout:fixed;
}
td {
padding:5px 10px;
}
td.set-width {
width:15px;
}
.box {
width:15px;
height:15px;
background-color:red;
}
<h2>Table-Layout: Auto</h2>
<table border="1" cellspacing="0" cellpadding="0" id="table-1">
<tr>
<td> </td>
<td class="set-width"><div class="box"></div></td>
</tr>
<tr>
<td> </td>
<td>unbroken</td>
</tr>
</table>
<h2>Table-Layout: Fixed</h2>
<table border="1" cellspacing="0" cellpadding="0" id="table-2">
<tr>
<td> </td>
<td class="set-width"><div class="box"></div></td>
</tr>
<tr>
<td> </td>
<td>unbroken</td>
</tr>
</table>
【问题讨论】:
-
关于这些解决方案如何提供帮助的任何更新?
-
我遇到了同样的事情。我们经常使用固定宽度的表格,它很好地在样式表中强制填充,因此您可以将文本转储到单元格中。自 2007 年以来一直存在于错误跟踪器中,这有点令人遗憾,而且它显然不符合规范。
标签: html css html-table webkit