CSS :nth-child(n) 選擇器的作用
使用 CSS :nth-child(n) 選擇器使用 CSS 對其父元素為第二個子元素的每個 <p> 元素進行樣式化。您可以嘗試執行以下程式碼來實現 :nth-child(n) 選擇器
示例
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-child(4) {
background: orange;
color: white;
}
</style>
</head>
<body>
<p>This is demo text 1.</p>
<p>This is demo text 2.</p>
<p>This is demo text 3.</p>
<p>This is demo text 4.</p>
<p>This is demo text 5.</p>
<p>This is demo text 6.</p>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP