[英]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.