nth-of-type和nth-child的区别
来源:互联网 发布:php yield 编辑:程序博客网 时间:2024/06/05 11:38
:nth-of-type(n) 选择器匹配属于父元素的特定类型的第 N 个子元素的每个元素.
:nth-child(n) 选择器匹配属于其父元素的第 N 个子元素,不论元素的类型。
示例
HTML<h1>这是标题</h1><p>第一个段落。</p><p>第二个段落。</p><p>第三个段落。</p><p>第四个段落。</p><p>第五个段落。</p>
a.cssp:nth-of-type(2){background:#ff0000;}b.cssp:nth-child(2){background:#ff0000;}
a.css中的css代码会使其父元素的第二个 p 元素的每个 p元素背景变红,即HTML中第二个段落背景变红。
b.css中的css代码会使其父元素的第二个子元素的每个 p 元素背景变红,即HTML中第一个段落背景变红。
阅读全文
0 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)的区别
- Android开源项目以及开源库集合(持续更新中)
- opengles加载xml格式的三维模型
- (130)固定光源
- 000043:在主方法中定义一维数组,并用foreach语句遍历该数组
- 数据存储BigDecimal形式
- nth-of-type和nth-child的区别
- QT工程打包发布
- Python-小习题-NO.2
- 快速了解友盟统计使用流程
- Segmentation fault (core dumped) --段错误
- ruby计算相差时间(秒)
- Aspose.Words使用模板导出数据库中图片内容
- 基于Quartus II和MATLAB的FIR滤波器设计与仿真(二)
- Intellij Idea免费激活方法