
- HTML中文网
- 联系QQ:88526
- QQ交流群
- 微信公众号

:nth-last-of-type() 选择器
含义和使用:
:nth-last-of-type(n)选择器匹配同类型中的倒数第n个同级兄弟元素。
n 可以是一个数字,一个关键字,或者一个公式
浏览器支持:
| 选择器 | ![]() | ![]() | ![]() | ![]() | ![]() |
| :nth-last-of-type() | 9.0 | 3.5 | 9.6 | 4.0 | 3.2 |
CSS语法:
:nth-last-of-type(n){
css语法
}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
p:nth-last-of-type(2)
{
background:pink;
}
</style>
</head>
<body>
<p>元素1</p>
<p>元素2</p>
<p>元素3</p>
</body>
</html>点击 "运行实例" 按钮查看在线实例
效果图:

推荐手册