gpt4 book ai didi

html - 具有多个表格的 CSS 表格边框

转载 作者:行者123 更新时间:2023-11-28 15:58:23 25 4
gpt4 key购买 nike

我在一页中有两个表格。我想围绕其中一个边界,而另一个没有边界。所以我正在使用 id=""。但它仍然在两张 table 周围设置边界,我不确定为什么。如果我将 table1 更改为无边框,它将取消两个表上的边框。请给我任何有用的链接或建议。谢谢。

table 
{
border-collapse: collapse;
}

#table1 td, tr
{
text-align:center;
border: 1px solid black;
}

#table1 th
{
background: orange;
}

#table2
{
margin:auto;
}
<table id = "table1">
<th> Header </th>
<tr>
<td>row 1</td>
</tr>
</table>

<table id = "table2">
<th> Header </th>
<tr>
<td>row 1</td>
</tr>
</table>

最佳答案

您必须在 #table1 td, tr 更改您的选择器。#table1 td 将应用于 #table1 中的所有 td,但是 tr 将应用于所有 tr

所以将它设置为 #table1 td, #table1 tr 就可以了。

#table1 td, #table1 tr
{
text-align:center;
border: 1px solid black;
}

Example

关于html - 具有多个表格的 CSS 表格边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40742235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com