(HTML)
<div>
<h2>I am another awesome h2</h2>
<p>number one paragraph</p>
<p>I'm the second paragraph inside this div!</p>
</div>
<p>PARAGRAPH NOT INSIDE A DIV</p>
<div>
<h2>A less awesome h2</h2>
<p>number one</p>
<p>One last paragraph here!</p>
</div>
(CSS)
我尝试使用nth-of-type和nth-child但我不能在SECOND DIV中选择两个P元素。
有人可以帮忙吗?
注意:我的网页中有太多P标签和DIV。我想选择不使用class或id的那些。
答案 0 :(得分:2)
div:nth-of-type(2) p {...}