nth-last-of-type选择器
来源:互联网 发布:选择框选中each数组 编辑:程序博客网 时间:2024/05/16 06:09
nth-last-of-type()选择器
规定属于其父元素的第二个 p 元素的每个 p,从最后一个子元素开始计数:p:nth-last-of-type(2){background:#ff0000;}。定义和用法:nth-last-of-type(n) 选择器匹配属于父元素的特定类型的第 N 个子元素的每个元素,从最后一个子元素开始计数。n 可以是数字、关键词或公式。“:nth-last-of-type(n)”选择器和“:nth-of-type(n)”选择器是一样的,选择父元素中指定的某种子元素类型,但它的起始方向是从最后一个子元素开始示例演示通过“:nth-last-of-type(n)”选择器将容器“div.wrapper”中的倒数第三个段落背景设置为橙色。HTML代码:<div class="wrapper"> <p>我是第一个段落</p> <p>我是第二个段落</p> <p>我是第三个段落</p> <p>我是第四个段落</p> <p>我是第五个段落</p> <div>我是一个Div元素</div> <p>我是第六个段落</p> <p>我是第七个段落</p></div>CSS代码:.wrapper > p:nth-last-of-type(3){ background: orange;}掩饰效果:实例 1Odd 和 even 是可用于匹配下标是奇数或偶数的子元素的关键词(第一个子元素的下标是 1)。 在这里,我们为奇数和偶数 p 元素指定两种不同的背景色,从最后一个子元素开始计数:p:nth-last-of-type(odd){background:#ff0000;}p:nth-last-of-type(even){background:#0000ff;}实例 2使用公式 (an + b)。描述:表示周期的长度,n 是计数器(从 0 开始),b 是偏移值。 在这里,我们指定了下标是 3 的倍数的所有 p 元素的背景色,从最后一个子元素开始计数:p:nth-last-of-type(3n+0){background:#ff0000;}
阅读全文
0 0
- nth-last-of-type选择器
- 【CSS3】nth-last-of-type(n)选择器
- 【CSS3】---last-of-type选择器+nth-last-of-type(n)选择器
- nth-of-type选择器
- last-of-type选择器
- CSS3 :nth-child() ,nth-of-type(),nth-last-child() ,nth-last-of-type()
- CSS3中nth-of-type和nth-last-of-type
- nth-of-type(n)选择器
- 【CSS3】last-of-type选择器
- 【CSS3】---first-of-type选择器+nth-of-type(n)选择器
- nth-child,nth-of-type,first-of-type,last-of-type,nth-last-of-type,only-of-type等的区别
- 【CSS3】nth-of-type(n)选择器
- CSS3选择器之nth-of-type
- CSS :nth-child与:nth-of-type选择器
- first-of-type,nth-of-type,last-of-type分类问题
- css中的first-child nth-child nth-last-child() 和:nth-of-type(n)
- first-child first-of-type last-child last-of-type 伪类选择器总结
- jQuery 选择器 first-child和first-of-type、 last-child和last-of-type的区别
- Java基础【01】this用法
- 四轴PID控制算法
- SDUT 3914 校赛~校赛~
- 前行
- mac环境下使用navicat premium连接mysql乱码问题
- nth-last-of-type选择器
- Centos下软件安装方法总结
- Spring+MyBatis整合使用
- 语法糖
- go交叉编译
- 双硬盘win7硬盘安装Ubuntu
- 如何去掉数据库重复记录并且只保留一条记录
- PHP截取后缀名的方法
- 《Java 多线程编程核心技术》学习笔记及总结