cSS3 伪类:nth-child 的使用方法
2014-12-04 10:55
337 查看
:nth-child是一个非常牛逼的伪类,如果你能很好的理解它就可以用CSS 做出很多非常实用的效果。当我很年轻的时候还使用PHP的i++来实现一些东西,其实CSS 完全可以实现。下面是我总结的一些用法,用了可爱的糖糖做演示,彩色头像就代表选中,T,T。
仅选择第5个
li:nth-child(5) { ... }
如果选择第一个元素的话你可以使用
:first-child或者用上面的方法。
除了前五个全部选择
li:nth-child(n+6) { ... }
只选择前5个
li:nth-child(-n+5) { ... }
从第一个开始,每隔4个选择一个
li:nth-child(4n-7) { /* or 4n+1 */ ... }
选择奇数或者偶数
li:nth-child(odd) { ... }
li:nth-child(even) { ... }
选择最后一个
li:last-child { ... }
选择倒数第二个
-EOF-
相关文章推荐
- CSS3 :nth-child()伪类选择器
- CSS3 :nth-child()伪类选择器
- CSS3---结构性伪类选择器—nth-child(n)
- CSS3:nth-child()伪类选择器,Table表格奇偶数行定义样式
- CSS3 :nth-child()伪类选择器实现奇偶行显示不同样式
- CSS3 :nth-child()伪类选择器
- CSS3 :nth-child()伪类选择器
- CSS3 :nth-child()伪类选择器
- CSS3类似循环的一个伪类 :nth-child
- CSS3 伪类选择器 nth-child()说明
- CSS3 :nth-child()伪类选择器
- CSS的nth-child使用方法
- CSS3---结构性伪类选择器—nth-last-child(n)
- 奇偶行显示不同样式操作,CSS3 :nth-child()伪类选择器
- CSS3 :nth-child()伪类选择器
- CSS3 :nth-child()伪类选择器
- CSS3 伪类选择器 nth-child()说明
- 【CSS3】---结构性伪类选择器—nth-child(n)+nth-last-child(n)
- CSS3 :nth-child()伪类选择器
- 【CSS3】---结构性伪类选择器—nth-child(n)+nth-last-child(n)