这两个css选择器之间的区别是什么? [英] whats the difference between these two css selectors?
本文介绍了这两个css选择器之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这两个选择器之间的区别,我认为他们会有相同的效果,但他们不?
Whats the difference between these two selectors, I thought they would have the same effect, but they don't? can someone explain please?
#parent-div #child-div
#parent-div#child-div
推荐答案
CSS选择器中的后代选择器。
The (space) in CSS selectors is the "descendant selector."
- 选择ID为
child-div
的元素具有parent-div 的父项
- 选择一个具有
parent-div
和child-div
(这是不可能的)
- Selects an element with ID
child-div
that has an ancestor ofparent-div
- Selects an element that has an id of both
parent-div
andchild-div
(which is impossible)
: parent-div#child-div
是一个有效的ID,但是作为CSS语法的一部分, code>#在规则集中:
Just for fun: parent-div#child-div
is a valid ID, but as part of the CSS syntax you have to escape the #
in the ruleset:
http://jsfiddle.net/ExplosionPIlls/xdWNV/1/
这篇关于这两个css选择器之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文