CSS3中:nth-child和:nth-of-type的区别深入理解
来源:互联网 发布:淘宝开店身份证照片图 编辑:程序博客网 时间:2024/05/22 08:13
关于:nth-child和:nth-of-type的区别之前一直没太注意。最近打算深入了解一些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,若不是,则选择失败。
<div> <ul class="demo"> <p>zero</p> <li>one</li> <li>two</li> </ul> </div>
上面这个例子,.demo li:nth-child(2)
选择的是<li>one</li>
节点,而.demo li:nth-of-type(2)
则选择的是<li>two</li>
节点。
阅读全文
0 0
- CSS3中:nth-child和:nth-of-type的区别深入理解
- CSS3中:nth-child和:nth-of-type的区别深入理解
- CSS3中:nth-child和:nth-of-type的区别
- CSS3中:nth-child和:nth-of-type的区别
- css3 :nth-child和:nth-of-type的区别
- css3中nth-child选择器和nth-of-type选择器的区别
- nth-child和nth-of-type区别
- :nth-child 和 :nth-type-of 的区别
- :nth-child 和 :nth-type-of 的区别
- :nth-child和:nth-of-type的区别
- 关于:nth-child和:nth-of-type的区别
- :nth-child和:nth-of-type的区别
- nth-child和nth-of-type的区别
- :nth-child和:nth-of-type的区别
- nth-of-type和nth-child的区别
- nth-of-type和nth-child的区别
- css :nth-child和:nth-of-type的区别
- CSS3中:nth-child()和nth-of-type()的却别
- java-抽象类
- mysql创建删除用户
- findContours
- 访问家庭内网资源
- [译] TensorFlow 白皮书
- CSS3中:nth-child和:nth-of-type的区别深入理解
- WiFi-ESP8266入门开发(四)-设置软热点
- R语言数据基础
- 技能系统
- 使用python 打开文件并做匹配处理
- 获取url路径
- 丑陋的字符串
- shell小技巧
- 19day- 真机调试