【发布时间】:2026-02-10 15:00:01
【问题描述】:
我对 css/html 表有疑问:
当我使用带有 colspan 属性的 thead 和 tbody 标记时,标题的底部边框被分割。
间隙大小取决于 th 边框宽度。
您是否有解决方案在标题底部获得连续边框(不删除 thead 和 tbody)?
table {
border-collapse: collapse;
}
th {
border: 4px solid red;
border-bottom: 4px solid black
}
td {
border: 4px solid blue;
}
thead tr {
border-bottom: 5px solid green
}
table {
border-collapse: collapse;
}
th {
border: 4px solid red;
border-bottom: 4px solid black
}
td {
border: 4px solid blue;
}
thead tr {
border-bottom: 5px solid green
}
with THEAD and TBODY but without COLSPAN
<table>
<thead>
<tr>
<th>
Column 1
</th>
<th>
Column 2
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Content 1
</td>
<td>
Content 2
</td>
</tr>
</tbody>
</table>
<br /> COLSPAN with THEAD and TBODY <span style="background:yellow">(css bug in the middle of green border ?)</span>
<table>
<thead>
<tr>
<th>
Column 1
</th>
<th>
Column 2
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">
Content 1 and 2 (merged cells)
</td>
</tr>
</tbody>
</table>
<br /> COLSPAN without THEAD and TBODY
<table>
<tr>
<th>
Column 1
</th>
<th>
Column 2
</th>
</tr>
<tr>
<td colspan="2">
Content 1 and 2 (merged cells)
</td>
</tr>
</table>
【问题讨论】:
-
你的需要就是你想要的。说清楚。
-
你是在什么浏览器上出现问题的?
-
@rewobs 我在 Mozilla 中看到了 OP 的问题,而不是在 Chrome 中。 screenshot。看起来像个bug。找不到解决方案或解决方法。
-
是的,问题出在 Mozilla。在 Chrome 中没问题。我需要一个连续的边框来分隔表头和表体。
标签: html css border html-table w3c