[英]CSS Div, classes and spans
Can some one please expalin to me these two selectors, I cant get my head around it 有人可以向我解释这两个选择器吗,我无法理解
div.card div
div.card div span
div.card div - all div's inside div with class card
div.card div-带有类
card
div内部的所有div
div.card div span - all span's inside div's inside div with class card
div.card div span-带类
card
所有div内部div内部div
Look at http://www.w3schools.com/cssref/css_selectors.asp 看看http://www.w3schools.com/cssref/css_selectors.asp
Whitespace in a selector means "descendant of", so div.card div
means "A div that is a descendant (eg, child, grandchild, great-grandchild) of a div with a class of card
". 选择器中的空白表示“的后代”,因此
div.card div
意思是“作为具有一类card
的div的后代(例如,子代,孙代,曾孙代)的div”。 div.card div span
means "a span that is a descendant of a div that is a descendant of a div with class card
." div.card div span
意思是“是div的后代,该div是具有class card
的div的后代。”
Given the HTML: 鉴于HTML:
<div id="d1" class="foo">
<div id="d2" class="card">
<span id="s1"></span>
<div id="d3" class="bar"></div>
<div id="d4" class="bar">
<div id="d5"><span id="s2"></span></div>
</div>
</div>
</div>
The selector div.card div
would match the divs with IDs d3
, d4
, and d5
. 选择器
div.card div
将匹配ID为d3
, d4
和d5
的div。 Note that it doesn't match the card
div (id d2
) itself. 请注意,它与
card
div(id d2
)本身不匹配。
The selector div.card div span
would match the span with id s2
, but NOT s1
. 选择器
div.card div span
将匹配ID为s2
的跨度,但不匹配s1
。 The s1
span does not descend from a div that is a child of div.card
, so it wouldn't match. s1
范围不是从div.card
的子级div div.card
,因此不会匹配。
Read from the right to the left: the first one is "div inside (div with class 'card')". 从右至左读取:第一个是“ div内部(具有'card'类的div)”。 The second one is "span inside div inside (div with class 'card')".
第二个是“在div内部(跨度为'card'类的div)内部”。
In HTML something like this: 在HTML中,如下所示:
div.card div div.card div
<div class="card">
<div></div>
</div>
div.card div span div.card div跨度
<div class="card">
<div>
<span></span>
</div>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.