请问 ul > li:first-child{ color: red; } 与 ul > li :first-child{ color: red; } (li与:first-child之间有空格)的差异

来源:6-6 CSS3 结构性伪类选择器—first-child

TWT

2015-09-13 12:27

请问为什么 ul > li:first-child{  color: red; } 显示 li 圆点为红色,而 ul > li :first-child{  color: red; } (li与:first-child之间有空格)却变成各 li 下的文字变成红色呢?请问是因为空格代表后代选择器吗?

写回答 关注

1回答

  • 3qfang
    2015-10-09 16:10:11
    已采纳

    li:first-child表示ul的第一个子元素;

    li :first-child无效的选择,选取为li

    TWT

    非常感谢!

    2015-10-10 21:01:56

    共 1 条回复 >

十天精通CSS3

本课程为CSS3入门教程,深刻详解CSS3知识让网页穿上绚丽装备

242220 学习 · 2623 问题

查看课程

相似问题