I have seen this character a number of times in CSS files but I have no idea how its used. Can anyone explain it to me and show how they are useful in making a page style easier?
我在CSS文件中见过很多次这个字符,但是我不知道它是如何使用的。有没有人能给我解释一下,并说明它们是如何使页面样式变得更容易?
4 个解决方案
#1
157
It's a CSS child selector. P > SPAN
means applying the style that follows to all SPAN tags that are children of a P
tag.
它是一个CSS子选择器。P > SPAN表示对所有SPAN标记(P标记的子标记)应用样式。
Note that "child" means "immediate descendant", not just any descendant. P SPAN
is a descendant selector, applying the style that follows to all SPAN
tags that are children of a P
tag or recursively children of any other tag that is a child/descendant of a P
tag. P > SPAN
only applies to SPAN
tags that are children of a P
tag.
注意,“child”的意思是“直接后代”,而不是任何后代。P SPAN是一个子代选择器,对所有的SPAN标记(P标记的子标记或P标记的子标记的递归子标记)应用样式。P > SPAN只适用于P标记的子跨度标记。
#2
103
p em
will match any <em>
that is within a <p>
. For instance, it would match the following <em>
s:
将匹配小于em>的任何
。例如,它将匹配以下s:
<p><strong><em>foo</em></strong></p>
<p>Text <em>foo</em> bar</p>
On the other hand,
另一方面,
p > em
Will match only <em>
s that are immediate children of <p>
. So it will match:
将只匹配s,它们是
的直接子代。所以它将匹配:
<p>Text <em>foo</em> bar</p>
But not:
而不是:
<p><strong><em>foo</em></strong></p>
#3
8
this is known as a Child Combinator:
这被称为子组合器:
A child combinator selector was added to be able to style the content of elements contained within other specified elements. For example, suppose one wants to set white as the color of hyperlinks inside of div tags for a certain class because they have a dark background. This can be accomplished by using a period to combine div with the class resources and a greater-than sign as a combinator to combine the pair with a, as shown below:
添加了子选择器,以便能够对包含在其他指定元素中的元素的内容进行样式化。例如,假设您想要将某个类的div标记中的超链接的颜色设置为白色,因为它们的背景是黑色的。这可以通过使用一个周期将div与类资源合并,并使用一个大于号作为组合符将二者与a合并,如下所示:
div.resources > a{color: white;}
(from http://www.xml.com/pub/a/2003/06/18/css3-selectors.html)
(来自http://www.xml.com/pub/a/2003/06/18/css3-selectors.html)
#4
4
E > F
Matches any F element that is a child of an element E.
匹配元素E的子元素F。
more on http://www.w3.org/TR/CSS21/selector.html#child-selectors
更多关于http://www.w3.org/TR/CSS21/selector.html子选择器
#1
157
It's a CSS child selector. P > SPAN
means applying the style that follows to all SPAN tags that are children of a P
tag.
它是一个CSS子选择器。P > SPAN表示对所有SPAN标记(P标记的子标记)应用样式。
Note that "child" means "immediate descendant", not just any descendant. P SPAN
is a descendant selector, applying the style that follows to all SPAN
tags that are children of a P
tag or recursively children of any other tag that is a child/descendant of a P
tag. P > SPAN
only applies to SPAN
tags that are children of a P
tag.
注意,“child”的意思是“直接后代”,而不是任何后代。P SPAN是一个子代选择器,对所有的SPAN标记(P标记的子标记或P标记的子标记的递归子标记)应用样式。P > SPAN只适用于P标记的子跨度标记。
#2
103
p em
will match any <em>
that is within a <p>
. For instance, it would match the following <em>
s:
将匹配小于em>的任何
。例如,它将匹配以下s:
<p><strong><em>foo</em></strong></p>
<p>Text <em>foo</em> bar</p>
On the other hand,
另一方面,
p > em
Will match only <em>
s that are immediate children of <p>
. So it will match:
将只匹配s,它们是
的直接子代。所以它将匹配:
<p>Text <em>foo</em> bar</p>
But not:
而不是:
<p><strong><em>foo</em></strong></p>
#3
8
this is known as a Child Combinator:
这被称为子组合器:
A child combinator selector was added to be able to style the content of elements contained within other specified elements. For example, suppose one wants to set white as the color of hyperlinks inside of div tags for a certain class because they have a dark background. This can be accomplished by using a period to combine div with the class resources and a greater-than sign as a combinator to combine the pair with a, as shown below:
添加了子选择器,以便能够对包含在其他指定元素中的元素的内容进行样式化。例如,假设您想要将某个类的div标记中的超链接的颜色设置为白色,因为它们的背景是黑色的。这可以通过使用一个周期将div与类资源合并,并使用一个大于号作为组合符将二者与a合并,如下所示:
div.resources > a{color: white;}
(from http://www.xml.com/pub/a/2003/06/18/css3-selectors.html)
(来自http://www.xml.com/pub/a/2003/06/18/css3-selectors.html)
#4
4
E > F
Matches any F element that is a child of an element E.
匹配元素E的子元素F。
more on http://www.w3.org/TR/CSS21/selector.html#child-selectors
更多关于http://www.w3.org/TR/CSS21/selector.html子选择器