I don't know how they are different in css
我不知道它们在css中的区别
something
{
//some properties
}
something >.somethingelse
{
// something else's properties
}
and
和
something
{
//some properties
}
something .somethingelse
{
// something else's properties
}
I don't know why there is such a >
in the second case. Should there also be a <
for use too ?
我不知道为什么在第二种情况下有这样一个>。是否也应该有一个< for use ?
3 个解决方案
#1
7
The >
indicates that direct children somethingelse
are found under something
. Otherwise descendants will be found at all levels.
>表示直接的孩子在某物下发现了其他的东西。否则将在各级找到后代。
So using this following example:
用下面这个例子:
<div class="something">
<div class="somethingelse">
<div class="somethingelse">
</div>
</div>
</div>
For the >
example only the outer somethingelse
div will take effect. For the example without >
both divs will have the style applied.
对于>示例,只有外部的somethingelse div会生效。对于没有>的示例,两个div都将具有应用样式。
<
might imply a parent selector (ie apply a style to the direct parent of a matching class). I'm not aware of this existing yet, but theres an interesting post on it a csstricks here.
<可能意味着父选择器(即将样式应用到匹配类的直接父类)。我还没有意识到这一点,但这里有一个有趣的帖子csstricks。< p>
#2
3
The >
selects any element with the class .somethingelse
which is a child of an element with the class .something
.
>选择类中的任何元素。其他元素是类元素的子元素。
The second CSS selector will select any descendents of the element with the class .something
. I.e. the children, and the childrens children, and so on.
第二个CSS选择器将选择具有.something类的元素的任何后代。也就是孩子,孩子的孩子,等等。
#3
0
>
selects direct descendants of something
that have class .somethingelse
>选择具有类的对象的直接后代
Currently there is no parent (<
) selector in CSS
目前在CSS中没有父(<)选择器
#1
7
The >
indicates that direct children somethingelse
are found under something
. Otherwise descendants will be found at all levels.
>表示直接的孩子在某物下发现了其他的东西。否则将在各级找到后代。
So using this following example:
用下面这个例子:
<div class="something">
<div class="somethingelse">
<div class="somethingelse">
</div>
</div>
</div>
For the >
example only the outer somethingelse
div will take effect. For the example without >
both divs will have the style applied.
对于>示例,只有外部的somethingelse div会生效。对于没有>的示例,两个div都将具有应用样式。
<
might imply a parent selector (ie apply a style to the direct parent of a matching class). I'm not aware of this existing yet, but theres an interesting post on it a csstricks here.
<可能意味着父选择器(即将样式应用到匹配类的直接父类)。我还没有意识到这一点,但这里有一个有趣的帖子csstricks。< p>
#2
3
The >
selects any element with the class .somethingelse
which is a child of an element with the class .something
.
>选择类中的任何元素。其他元素是类元素的子元素。
The second CSS selector will select any descendents of the element with the class .something
. I.e. the children, and the childrens children, and so on.
第二个CSS选择器将选择具有.something类的元素的任何后代。也就是孩子,孩子的孩子,等等。
#3
0
>
selects direct descendants of something
that have class .somethingelse
>选择具有类的对象的直接后代
Currently there is no parent (<
) selector in CSS
目前在CSS中没有父(<)选择器