是否可以一次给表格行加上边框 <tr>
而不是给单个单元格加上边框, <td>
就像,
<table cellpadding="0" cellspacing="0" width="100%" style="border: 1px;" rules="none">
<tbody>
<tr>
<th style="width: 96px;">Column 1</th>
<th style="width: 96px;">Column 2</th>
<th style="width: 96px;">Column 3</th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td style="border-left: thin solid; border-top: thin solid; border-bottom: thin solid;"> </td>
<td style="border-top: thin solid; border-bottom: thin solid;"> </td>
<td style="border-top: thin solid; border-bottom: thin solid; border-right: thin solid;"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
这给出了给定 <tr>
周围的边框,但它需要单个单元格周围的边框。
我们可以一次给 <tr>
一个边框吗?
原文由 Tiny 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以在
tr
元素上设置border
属性,但根据 CSS 2.1 规范,此类属性在分隔边框模型中无效,这往往是浏览器中的默认设置。参考:17.6.1 分离边界模型。 (根据CSS 2.1,—的 初始 值为border-collapse
separate
部分浏览器也将其设置为table
的 默认值 除非您明确指定collapse
,否则几乎所有浏览器都会出现分隔边框。)因此,您需要使用折叠边框。例子: