[英]Styling <p> tag inside <div> by using CSS
(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 的。
在这种情况下使用选择器非常简单,只需尝试
div:nth-of-type(2) p {...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.