first-child 伪类
导读:您兴许运用 :first-child 伪类来决意元素的第一个子元素。这个特定伪类很简单受到误会,以是有需要举例来阐明。思虑如下符号: These are the necessary steps: Intert Key Turn key...
您兴许运用 :first-child 伪类来决意元素的第一个子元素。这个特定伪类很简单受到误会,以是有需要举例来阐明。思虑如下符号:
These are the necessary steps:
- Intert Key
- Turn key clockwise
- Push accelerator
Do not push the brake at the same time as the accelerator.
在上面的例子中,作为第一个元素的元素包孕第一个 p、第一个 li 和 strong 和 em 元素。
给定如下划定规矩:
p:first-child { font-weight: bold; } li:first-child { text-transform:uppercase; }
第一个规则将作为某元素第一个子元素的悉数 p 元素配置为粗体。第二个规定将作为某个元素(在 HTML 中,这必然是 ol 或 ul 元素)第一个子元素的所有 li 元素变成大写。
请接见该链接,来搜检这个:first-child 实例的效果。
示意:最常见的舛错是以为 p:first-child 之类的决议器会选择 p 元素的第一个子元素。
剖明:必须声明,这样 :first-child 才略在 IE 中见效。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: first-child 伪类
本文地址: https://pptw.com/jishu/665894.html