CSS :last-of-type 偽類
示例
為父元素的最後一個 <p> 元素和最後一個 <li> 元素指定背景顏色
p:last-of-type {
background-color: yellow;
}
li:last-of-type {
background-color: yellow;
}
自己動手試一試 »
定義和用法
`:last-of-type` 偽類匹配父元素的最後一個同類型子元素。
提示:這等同於 :nth-last-of-type(1)。
版本 | CSS3 |
---|
瀏覽器支援
表中數字表示該偽類完全支援的第一個瀏覽器版本。
偽類 | |||||
---|---|---|---|---|---|
:last-of-type | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
CSS 語法
相關頁面
CSS 參考::last-child