CSS3子元素选择方法nth-child和nth-of-type
2014-11-02 21:13
591 查看
ele:nth-child是选择第n个元素且为ele,若类型不匹配,则返回false;
nth-of-type是按类型来选,即选择第n个ele元素,其他类型的子元素不计入n的计算。
用一个简单的实例来说明其使用方法和区别:
http://wow.techbrood.com/fiddle/2569
nth-of-type是按类型来选,即选择第n个ele元素,其他类型的子元素不计入n的计算。
用一个简单的实例来说明其使用方法和区别:
<div class="wrapper"> <ul class="demo"> <h1>CSS3 Basics</h1> <li>nth-child(2) selector</li> <li>nth-of-type(2) selector</li> <el>nth-child not match</el> </ul> </div>
.wrapper { padding: 20px 50px; background: black; font-size: 20px; } h1,el { color: white; } .demo li:nth-child(2) { color: orange; } .demo li:nth-of-type(2) { color: green; font-size: 28px; } .demo li:nth-child(4) { color: orange; }代码自解释,在线演示地址:
http://wow.techbrood.com/fiddle/2569
相关文章推荐
- :nth-of-type(n)父类中选择元素的第几个 :nth-child(n) 选择某个元素且是父类的第几个元素
- 选择最后一个元素 及nth-child和nth-of-type的区别
- CSS nth-child、first-child、last-child、nth-of-type、first-of-type和last-of-type选择器使用
- css :nth-child和:nth-of-type的区别
- CSS中nth-child和nth-of-type的区别
- CSS :nth-child与:nth-of-type选择器
- CSS学习笔记(10)--nth-child和nth-of-type
- 选择中的:nth-child(n)和:nth-of-type(n)的区别
- css nth-child和nth-type-of 区别
- css :nth-child与:nth-of-type之小解
- CSS nth-child、first-child、last-child、nth-of-type、first-of-type和last-of-type选择器使用
- CSS伪类选择器nth-child 选择3的倍数个元素写法
- css nth-child(n)和nth-of-type(n)区别
- CSS中nth-child和nth-of-type的简单使用
- CSS3伪类选择器:nth-child(n)及:nth-of-type(n)使用区别探究总结
- 使用css属性:nth-child(n)匹配选择第n个子元素
- CSS 中 nth-child 和 nth-of-type 的区别
- css 伪类选择器 :nth-child(n) 与:nth-of-type(n)的区别
- css中的first-child nth-child nth-last-child() 和:nth-of-type(n)
- CSS3的nth-child() 和nth-of-type()选择器,表格奇偶行变色