首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

css3之:nth-child伪种选择器

2012-08-25 
css3之:nth-child伪类选择器CSS3之:nth-child伪类选择器????:nth-child(number) -----匹配第number个元素,

css3之:nth-child伪类选择器

CSS3之:nth-child伪类选择器

?

?

??:nth-child(number) -----匹配第number个元素,参数number必须大于0的整数举例:li:nth-child(5){color:green;}?

css3之:nth-child伪种选择器
?
??:nth-child(an) ------匹配所有倍数为a的元素。其中参数an中的字母n不能缺省。??:nth-child(an+b) |:nth-child(an-b) ?------倍数分组匹配,其中a,b均为正整数或0,举例:li:nth-child(4n+1){color:green;} ?或者是4n-7
css3之:nth-child伪种选择器
?
??:nth-child(-an+b) ?反向倍数分组匹配 ?------从第b个开始往回算,最多也不会超过b个举例:li:nth-child(-n+5){color:green;} ?


css3之:nth-child伪种选择器

?

??:nth-child(odd) ? ?-----匹配序号为奇数,和2n+1一样举例:li:nth-child(odd){color:green;}

css3之:nth-child伪种选择器
???:nth-child(even) ?-----匹配序号为偶数,和2n+0或者2n一样举例:li:nth-child(even){color:green;}

css3之:nth-child伪种选择器
???:nth-last-child(n) ?----选择某个字元素,从最后一个数起举例:li:nth-last-child(2){color:green;}
css3之:nth-child伪种选择器
???:nth-of-type(n) ? ?----选择某个某种类型的子元素??:nth-last-of-type(n) ? ----选择某个某种类型的子元素,从最后一个符合条件的元素数起??:last-child ?------最后一个子元素举例:li:last-child{color:green;}?css3之:nth-child伪种选择器?
浏览器支持:?? 对应IE来讲:IE7支持:last-child,其他的IE9支持???Opera9+和Safari3+等现代浏览器支持的比较好



扩展阅读:
1、http://css-tricks.com/useful-nth-child-recipies/

热点排行