gpt4 book ai didi

css - :not() not working as expected

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

使用 :not() 运算符有什么限制吗?

我有这个 HTML:

<table>
<thead>
<th>AAAAAAA</th>
<th>VVVVVVVVVVV</th>
</thead>
<tr>
<td>111111</td>
<td>22222</td>
</tr>
</table>
<br>
<br>
<br>
<br>
<table class="t">
<thead>
<th>AAAAAAA</th>
<th>VVVVVVVVVVV</th>
</thead>
<tr>
<td>111111</td>
<td>22222</td>
</tr>
</table>

还有这个 CSS:

table td:not(.t) {
border: 1px solid black;
padding-left: 5px;
}


table th:not(.t) {
border: 1px solid black;
padding-left: 5px;
}

然而,这两个表都获得了 CSS 规则。 Jsfiddle

最佳答案

这是因为 .t 应用于 table 而不是 td

试试这个:

table:not(.t) td
{
...
}

table:not(.t) td, table:not(.t) th
{
border: 1px solid black;
padding-left: 5px;
}

刚注意到,您也可以对声明进行分组,因为它们是相同的。

关于css - :not() not working as expected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23659397/

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