为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

正在回答

代码语言

1 回答

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

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

1 回复 有任何疑惑可以回复我~
#1

TWT 提问者

非常感谢!
2015-10-10 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

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

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号