css中的'>'符号是什么意思? [重复]

时间:2022-08-15 16:56:50

This question already has an answer here:

这个问题在这里已有答案:

Easy points here for anyone who knows. I am looking for a detailed answer on what it (>) means and how it should be used. Thanks.

对于任何知道的人来说这里都很容易我正在寻找关于它(>)意味着什么以及如何使用它的详细答案。谢谢。

3 个解决方案

#1


4  

There is no valid symbol as < in CSS. If you use it, you will invalidate your css.

CSS中没有有效的符号<。如果您使用它,您将使您的CSS无效。

However, you may want to use > - the child selector.

但是,您可能希望使用> - 子选择器。

CSS4 will introduce a subject selector. At the moment it is marked with $.

CSS4将引入一个主题选择器。目前它标有$。

so

所以

$#parent a:hover{
   /* styles */
}

so these rules will not apply to the a in hoverstate, but it's parent with the parent-ID. CSS4 spec

所以这些规则不适用于hoverstate中的a,但它是父ID的父级。 CSS4规范

#2


4  

The < is not valid CSS, you should not use it anywhere in your CSS.

<无效的css,你不应该在css的任何地方使用它。< p>

#3


1  

You may be thinking of the > (great than symbol) selector.

你可能会想到>(伟大的符号)选择器。

This selector is known as the child combinator selector.

此选择器称为子组合子选择器。

This means it will only select direct children of the parent. For example:

这意味着它只会选择父母的直接子女。例如:

ul > li

So for example, if you wanted to style a nested unordered list as such:

因此,例如,如果您想要将嵌套的无序列表设置为这样:

<ul>
<li></li>
    <li>
       <ul>
       </ul>
    </li>
</ul>

You would have to style it as such:

你必须这样设计:

ul > li > ul

But this is only in the case of using >, child combinator selector.

但这只是在使用>,儿童组合选择器的情况下。

#1


4  

There is no valid symbol as < in CSS. If you use it, you will invalidate your css.

CSS中没有有效的符号<。如果您使用它,您将使您的CSS无效。

However, you may want to use > - the child selector.

但是,您可能希望使用> - 子选择器。

CSS4 will introduce a subject selector. At the moment it is marked with $.

CSS4将引入一个主题选择器。目前它标有$。

so

所以

$#parent a:hover{
   /* styles */
}

so these rules will not apply to the a in hoverstate, but it's parent with the parent-ID. CSS4 spec

所以这些规则不适用于hoverstate中的a,但它是父ID的父级。 CSS4规范

#2


4  

The < is not valid CSS, you should not use it anywhere in your CSS.

<无效的css,你不应该在css的任何地方使用它。< p>

#3


1  

You may be thinking of the > (great than symbol) selector.

你可能会想到>(伟大的符号)选择器。

This selector is known as the child combinator selector.

此选择器称为子组合子选择器。

This means it will only select direct children of the parent. For example:

这意味着它只会选择父母的直接子女。例如:

ul > li

So for example, if you wanted to style a nested unordered list as such:

因此,例如,如果您想要将嵌套的无序列表设置为这样:

<ul>
<li></li>
    <li>
       <ul>
       </ul>
    </li>
</ul>

You would have to style it as such:

你必须这样设计:

ul > li > ul

But this is only in the case of using >, child combinator selector.

但这只是在使用>,儿童组合选择器的情况下。