nth-child和nth-of-type的区别
来源:互联网 发布:斑马梦龙网络计划心得 编辑:程序博客网 时间:2024/05/28 23:11
在css3选择器中的nth-child可以选择父元素下的字元素,但是nth-of-type也可以选择。但是它们到底有什么区别呢?
- nth-of-type为什么要叫:nth-of-type?因为它是以”type”(类型)来区分的;
- nth-of-type(n)是指父元素下第n个ele元素
- nth-child(n)是指父元素下第n个元素且这个元素为ele,若不是,则选择失败。
例子如下所示:
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> li:nth-child(3){ background:#00BFFF; } li:nth-of-type(3){ background: red; } </style> </head> <body> <ul> <p>ppppppp</p> <d>ppppppp</d> <li>111111</li> <li>222222</li> <li>333333</li> <li>444444</li> </ul> </body></html>
效果如下图所示:
1 0
- nth-child和nth-of-type区别
- :nth-child 和 :nth-type-of 的区别
- :nth-child 和 :nth-type-of 的区别
- CSS3中:nth-child和:nth-of-type的区别
- CSS3中: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-child和:nth-of-type的区别
- nth-of-type和nth-child的区别
- nth-of-type和nth-child的区别
- css3 :nth-child和:nth-of-type的区别
- css :nth-child和:nth-of-type的区别
- nth-child()与nth-of-type()区别
- css nth-child(n)和nth-of-type(n)区别
- css nth-child和nth-type-of 区别
- :nth-child(n)与:nth-of-type(n)的区别
- Hibernate流程解析
- 历届试题 兰顿蚂蚁
- 36、乘法
- 307. Range Sum Query - Mutable**
- Win7系统使用--Win7无法连接wifi问题的解决方法
- nth-child和nth-of-type的区别
- HP打印机驱动程序下载
- Bigtable的些许重点
- c++异常积累
- 【u227】BOOK
- 蓝桥杯搭积木问题DFS
- 八种常用的排序方法
- LINUX下的51单片机LED 渐亮渐灭实验
- ID Codes POJ - 1146