CSS \9 in width 属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8004765/
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
CSS \9 in width property
提问by well actually
What is the meaning of this? I am guessing it is a browser hack, but I have not been able to find what exactly it does.
这是什么意思?我猜这是一个浏览器黑客,但我一直无法找到它到底做了什么。
width: 500px;
What is the significance of \9?
有什么意义\9?
回答by Sparky
\9is a "CSS hack" specific to Internet Explorer 7, 8, & 9.
\9是特定于 Internet Explorer 7、8 和 9 的“CSS hack”。
This simply means that the one specific line of CSS ending with a \9;in place of the ;is only valid in IE 7, 8, & 9.
这只是意味着以 a\9;代替the 的一行特定 CSS;仅在 IE 7、8 和 9 中有效。
In your example,
在你的例子中,
width: 500px\9;means that a width of 500 pixels (same result as width: 500px;) will only be applied while using IE 7, 8, & 9.
width: 500px\9;意味着width: 500px;只有在使用 IE 7、8 和 9 时才会应用500 像素的宽度(与 相同的结果)。
All other browsers will ignore width: 500px\9;entirely, and therefore not apply width: 500px;to the element at all.
所有其他浏览器将width: 500px\9;完全忽略,因此根本不适width: 500px;用于该元素。
If your CSS looked like this...
如果你的 CSS 看起来像这样......
#myElement {
width: 300px;
width: 500px;
}
The result would be #myElement500 pixels wide in IE 7, 8, & 9, while in all other browsers, #myElementwould be 300 pixels wide.
结果#myElement在 IE 7、8 和 9 中为500 像素宽,而在所有其他浏览器中#myElement为 300 像素宽。
EDIT:
编辑:
This answer was written in 2011. It should now be noted that this hack also works in IE 10.
这个答案是在 2011 年写的。 现在应该注意这个 hack 也适用于 IE 10。
回答by sandeep
It's a css hack for IE9 & below version
这是 IE9 及以下版本的 css hack
write like this:
像这样写:
width: 500px;
Read this article http://dimox.net/personal-css-hacks-for-ie6-ie7-ie8/
回答by gordi
CSS Hack for IE9
适用于 IE9 的 CSS 黑客
/* Hack CSS IE9 */
.csshackie9 {color:#f00.align {
float:left;
margin:5px;
background-color:blue;
width:65px;
width: !important;
}
\;}
回答by Asad Shah
In IE9 to set the width property you just add this hack.
在 IE9 中设置宽度属性你只需添加这个 hack。
e.g
例如
##代码##
