* CSS操作符是什么?有没有其他的CSS操作符? [英] What does the * CSS operator do? Are there any other CSS operators?

查看:191
本文介绍了* CSS操作符是什么?有没有其他的CSS操作符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在学习如何从CSS中的列表元素构建嵌套表时,我偶然发现了这个页面: http://css.maxdesign.com.au/listamatic2/horizo​​ntal01.htm



我注意到样式表使用了几个符号,在CSS中不熟悉,即> * 符号,似乎是某种类型的CSS运算符。



例如:

  ul #navlist li * a:link,ul#navlist li * a:visited 

并且发现> 只是表示两个元素之间的父/子关系,但我仍然不知道 * 。我也很想知道是否还有其他的操作符,如果是这样,可以有人指示我参考所有这些?

解决方案

* 通用选择器。它选择任何元素。



但是,它是一个简单选择器,因此它不属于与所谓的组合器(表示两个元素之间的关系)。 > 是子组合器,如你所说的定义两个元素之间的父子关系。



ul#navlist li li code> * 等都是后代组合器。与> 不同,该空格并不表示父子关系;它只是要求一个元素包含在某处,无论是一个孩子,孙子,孙子等,但不是兄弟姐妹。



/ em>这两个选择器之间(从你的链接):

  ul#navlist li& a:link,ul#navlist li> a:visited 
ul#navlist li * a:link,ul#navlist li * a:visited

是第一个使用> 要求 a:link a :直接位于 ul#navlist li 元素中的元素



,而第二个与 * 要求 a:link a :<@ code>元素

位于 ul#navlist li 内的任何元素内。

换句话说, a:link,a:visited 不能直接 li


While studying how to build a nested table from list elements in CSS, I stumbled across this page: http://css.maxdesign.com.au/listamatic2/horizontal01.htm.

I noticed that the stylesheet uses a few symbols I'm not familiar with in CSS, namely the > and * symbols as what seem to be some kind of CSS operators.

For example:

ul#navlist li * a:link, ul#navlist li * a:visited

I was able to Google and find out that > simply indicates a parent/child relationship between two elements, but I still have no idea what * does. I'm also curious to know whether or not there are other "operators" like these, and if so, could somebody direct me to a reference of all of them?

解决方案

* is the universal selector. It selects any element.

However, it's a simple selector, and as such it doesn't belong in the same family as what are called combinators (which indicate relationships between two elements). > is the child combinator, which as you say defines a parent-child relationship between two elements.

The spaces between ul#navlist and li, li and *, etc are all descendant combinators. Unlike >, the space doesn't indicate a parent-child relationship; it just asks for an element that's contained somewhere within, whether it's a child, grandchild, great-grandchild, etc, but not a sibling.

The difference between these two selectors (from your link):

ul#navlist li > a:link, ul#navlist li > a:visited
ul#navlist li * a:link, ul#navlist li * a:visited

Is that the first one with > asks for a:link and a:visited elements
that sit directly within ul#navlist li elements,

while the second one with * asks for a:link and a:visited elements
that sit within any element that's within ul#navlist li.
In other words, a:link, a:visited that's not directly within ul#navlist li.

这篇关于* CSS操作符是什么?有没有其他的CSS操作符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆