usage of * symbol in css

女生的网名这么多〃 提交于 2019-12-11 04:43:01

问题


I found some stylesheets using * symbol on it. for example *zoom: 1; what does the * symbol stands. sometimes which appears like [class*="span"] this. can anybody clear me the usage of the symbol * in css


回答1:


*zoom is a hack that applies it ie6 and ie7. * { } is a wildcard (matches all elements or subset; if used like #header * it would apply to all descendants of #header). [class*="span"] matches elements that have a class with the word "span" anywhere.




回答2:


If * is used an independent selector, it means all. But if used inside the attribute selector [ ], it means "contains". For example, you have

[class*="span"]

. It means, it will select all elements that has a class which has a "span" somewhere in the class name.

It also used as CSS hack if it's inside the style value.




回答3:


It is a wildcard which select all elements.

For example, if you apply margin to every element on entire page you can use:

* {
    margin: 50px;
}

You can also use this within sub-selections, for example the following would add a margin to all elements within a paragraph tag:

p * {
    margin: 10px;
}

See this:- http://www.stackoverflow.com/a/1204290/2256325

Regarding you example, let me tell you that if you add asterisk (*) immediately before a property name, the property will be applied in IE and not in other browsers. Its only applicable to version 7 or below .

Source :-http://www.javascriptkit.com/dhtmltutors/csshacks3.shtml




回答4:


In addition to using the asterisk (at the start of a property name) to select only for older IE browsers, for CSS the many varied details are at w3.org:

CSS2.1 -- http://www.w3.org/TR/CSS21/selector.html

CSS3 -- http://www.w3.org/TR/css3-selectors/



来源:https://stackoverflow.com/questions/17510075/usage-of-symbol-in-css

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!