CSS3 :nth-last-of-type() 选择器

定义和用法

:nth-last-of-type(n)选择器匹配同类型中的倒数第n个同级兄弟元素。

n 可以是一个数字,一个关键字,或者一个公式。

提示:请参阅:nth-last-child()选择器。该选择器匹配父元素中的倒数第n个结构子元素


浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

选择器ChromeIEFirefoxSafariOpera
:nth-last-of-type()4.09.03.53.29.6

实例

指定每个p元素匹配同类型中的倒数第2个同级兄弟元素背景色:

p:nth-last-of-type(2)
{
background:#ff0000;
}