[英]Styling <p> tag inside <div> by using CSS
(HtMl) (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) (CSS)
I tried to use nth-of-type and nth-child but I cannot choose the two P element inside SECOND DIV.我尝试使用 nth-of-type 和 nth-child 但我无法选择 SECOND DIV 中的两个 P 元素。
Can anyone help?任何人都可以帮忙吗?
Note: I have too many P tag and DIV inside my webpage.注意:我的网页中有太多 P 标签和 DIV。 I want to choose those without using class or id.
我想选择那些不使用 class 或 id 的。
在这种情况下使用选择器非常简单,只需尝试
div:nth-of-type(2) p {...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.