Consider this HTML:
<p>Foo</p>
<p>
<br>
</p>
<p>Bar</p> <!-- I want to select this p element -->
<p>Baz</p>
Is there any way in CSS to select "the p
element after a p
element containing a br
element"?
I know I can fall back to using JavaScript for this, but I was curious to see if there was some funky combination of sibling selectors, or some magical pseudoclass I'm yet to come across.
答案 0 :(得分:-2)
在此给定代码中
`
Foo
酒吧
Baz
`
如果要选择第3个p,则可以使用伪类:nth-child()
因此答案将是p:nth-child(3)
如果这些p标签位于容器内,而不是将其用作组合器以获得所需的结果,否则它将选择html文档中的所有第3个p标签