星号在 CSS 属性名称中有什么作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4563651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 23:23:18  来源:igfitidea点击:

What does an asterisk do in a CSS property name?

css

提问by Avery

I know what an asterisk does in a selector for CSS (What does an Asterisk do?), but what does it do in a property name? Here is an example of CSS used by YUI. I don't know what the *displaydoes.

我知道星号在 CSS 选择器中的作用(星号有什么作用?),但它在属性名称中的作用是什么?这是 YUI 使用的 CSS 示例。不知道有什么*display作用

.yui-button .first-child
{
    display:block;
    *display:inline-block;
}

回答by Quentin

It is a syntax error. So in CSS, it makes the property name invalid and stops it being parsed.

这是一个语法错误。因此,在 CSS 中,它会使属性名称无效并停止对其进行解析。

Thanks to bugs in browsers, it is sometimes ignored. This effectively causes the property to apply only to browsers featuring that particular bug — IE7.

由于浏览器中的错误,它有时会被忽略。这有效地导致该属性仅适用于具有该特定错误 - IE7 的浏览器。

In general, it should be avoided in favour of conditional comments.

一般来说,应该避免使用条件注释。

回答by BoltClock

It's an IE hack. The second declaration will be applied by IE7 and older (thus overriding the first declaration), while other browsers will ignore it and continue applying the first declaration instead.

这是一个 IE 黑客。第二个声明将由 IE7 及更早版本应用(因此覆盖第一个声明),而其他浏览器将忽略它并继续应用第一个声明。

Also, this is invalid CSS syntax.

此外,这是无效的 CSS 语法。

回答by guy schaller

its like the underscore for ie6. but for ie7

它就像 ie6 的下划线。但对于 ie7

if you put the asterisk the property will only be used in ie7 and older browsers.

如果您放置星号,则该属性将仅在 ie7 和更旧的浏览器中使用。

its an hack...

这是一个黑客...

回答by mingos

It's one of the IE hacks. Internet Explorer parses CSS in a slightly different way, allowing for certain hacks that will be ignored in other browsers. Google for it. You can target different versions of IE with different hacks.

这是 IE 黑客之一。Internet Explorer 以稍微不同的方式解析 CSS,允许某些在其他浏览器中会被忽略的 hack。谷歌一下。您可以使用不同的 hacks 来定位不同版本的 IE。