4

我想选择所有不遵循 H3 或 P 的 P 所以:

<img>

<p> this is selected</p>

<p> this is not</p>

<p> this is not</p>

<span>

<p> this is selected</p>

<h3>

<p> this is not</p>

我试过

p + :not(h3, p) and :not(h3, p) + p

但他们不工作

解决办法是什么?请帮忙

4

3 回答 3

5

您可以通过这种方式将其表达为 css 选择器:

*:not(h3):not(p) + p

查看工作演示

于 2012-11-03T20:03:33.827 回答
0
:not(h3):not(p) + p {
    ...
}

​</p>

于 2012-11-03T20:08:03.707 回答
-1

使用这样的类...

<img>
<p class="sel"> this is selected</p>
<p> this is not</p>
<p> this is not</p>
<span>
<p class="sel"> this is selected</p>
<h3>
<p> this is not</p>

然后在你的CSS中你可以修改它们......

.sel {
   /* Styling here */
}
于 2012-11-03T19:59:28.740 回答