最新下载
热门教程
- 1
 - 2
 - 3
 - 4
 - 5
 - 6
 - 7
 - 8
 - 9
 - 10
 
详解CSS3中nth-child与nth-of-type的区别
时间:2022-06-25 08:55:24 编辑:袖梨 来源:一聚教程网
CSS3中nth-child与nth-of-type的区别其实很简单::nth-of-type为什么要叫:nth-of-type?因为它是以"type"来区分的。也就是说:ele:nth-of-type(n)是指父元素下第n个ele元素, 而ele:nth-child(n)是指父元素下第n个元素且这个元素为ele,若不是,则选择失败。
文字未免听起来比较晦涩,便于理解,这里附上一个小例子:
| 
             .demo li:nth-child(2){ 
            color: #ff0000; 
            } 
            .demo li:nth-of-type(2){ 
            color: #00ff00; 
            } 
            
            
            zero  |