gpt4 book ai didi

html - 如何删除这张 table 内壁上的 'double border'? CSS

转载 作者:太空宇宙 更新时间:2023-11-04 13:15:59 25 4
gpt4 key购买 nike

我有以下 HTML 和 CSS:

HTML

<table>
<tbody>
<tr>
<td>Row one, cell one</td>
<td>Row one, cell two</td>
</tr>
<tr>
<td>Row two, cell one</td>
<td>Row two, cell two</td>
</tr>
<tr>
<td>Row three, cell one</td>
<td>Row four, cell two</td>
</tr>
<tr>
<td>Row three, cell one</td>
<td>Row four, cell two</td>
</tr>
<tr>
<td>Row three, cell one</td>
<td>Row four, cell two</td>
</tr>
<tr>
<td>Row three, cell one</td>
<td>Row four, cell two</td>
</tr>
<tr>
<td>Row three, cell one</td>
<td>Row four, cell two</td>
</tr>
</tbody>
</table>

CSS

tbody tr:last-child td:first-child {
border-radius: 0 0 0 0.6em;
}
tbody tr:last-child td:last-child {
border-radius: 0 0 0.6em 0;
}
tbody tr:first-child td:first-child {
border-radius: 0.6em 0 0 0;
}
tbody tr:first-child td:last-child {
border-radius: 0 0.6em 0 0;
}

http://jsfiddle.net/daft/LwT7k/

如果你检查表格,你会看到它有

border-collapse: seperate;
border-spacing: 0;

无论出于何种原因,这些都是获得 flex 边缘所必需的。不幸的是,这也会导致每个单元格的内壁都有一个边框,当细胞一起塌陷时,似乎内壁都有双倍厚的边框。

有没有办法用纯 CSS 或 HTML 来解决这个问题?

最佳答案

像下面这样更新你的 CSS。

table {
border-spacing: 0;
}
th, td {
border-bottom:1px solid #000;
border-left:1px solid #000;
padding: 0.5em 1em;
}

tbody tr:last-child td:first-child {
border-radius: 0 0 0 0.6em;
}
tbody tr:last-child td:last-child {
border-radius: 0 0 0.6em 0;
}
tbody tr:first-child td:first-child {
border-radius: 0.6em 0 0 0;
border-top:1px solid #000;
}
tbody tr:first-child td:last-child {
border-radius: 0 0.6em 0 0;
border-top:1px solid #000;
}
tbody tr td:last-child{
border-right:1px solid #000;
}

FIDDLE DEMO

关于html - 如何删除这张 table 内壁上的 'double border'? CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24405821/

25 4 0