CSS :last-of-type 選擇器的作用
使用 CSS :last-child 選擇器為其父元素的最後一個子元素的每個 <p> 元素設定樣式。
示例
您可以嘗試執行以下程式碼來實現 :last-child 選擇器 -
<!DOCTYPE html>
<html>
<head>
<style>
p:last-of-type {
background: orange;
}
</style>
</head>
<body>
<h2>Heading</h2>
<p>This is demo text1.</p>
<p>This is demo text2.</p>
<p>This is demo text3.</p>
</body>
</html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP