问题
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