CSS子对象选择器 [英] CSS Child vs Descendant selectors
本文介绍了CSS子对象选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有点困惑这两个选择器之间。 后代选择器:
I am a bit confused between these 2 selectors. Does the descendent selector:
div p
在 div
中选择全部 p
或者不是立即下定决心?因此,如果 p
在另一个 div
中,它仍会被选中?
select all p
within a div
whether or not it's an immediate descedent? So if the p
is inside another div
it will still be selected?
然后子选择器:
div > p
有什么区别?孩子是否意味着即时孩子?例如
Whats the difference? Does a child mean immediate child? Eg.
<div><p>
vs
<div><div><p>
将被选中吗?
推荐答案
想想英语中child和descendant的意思:
Just think of what the words "child" and "descendant" mean in English:
- 我的女儿既是我的孩子也是我的后代
- 我的孙女不是我的孩子,但她是我的后代。
这篇关于CSS子对象选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文