[英]Backslash in CSS padding shorthand declaration
The website Qq.com has a rule-set with two padding declarations which seem a bit strange. 网站Qq.com有一个带有两个填充声明的规则集,看起来有点奇怪。 My question is, what does the
11px\\0
part do? 我的问题是,
11px\\0
部分做了什么? Does this have something to do with overriding the first padding declaration? 这是否与覆盖第一个填充声明有关? I understand the use of the slash in situations like these: / (forward slash) in css style declarations , but I have never seen something like this.
我理解在这样的情况下使用斜杠: /(正斜杠)在css样式声明中 ,但我从未见过这样的东西。
.suggestion .s_title {
padding: 3px 0 1px 11px;
padding: 4px 0 1px 11px\0;
color: #a0a3a8;
font-size: 12px;
line-height: 18px;
}
"Backslash zero" is a css hack targeting IE8 for the current rule. “反斜杠零”是针对当前规则的针对IE8的css hack。 This can be a terrible thing to do, unless there is no other choices.
这可能是一件可怕的事情,除非没有其他选择。 What happens is that IE8 will erroneously believe that this is a valid rule to be applied while other browsers won't, leaving you with a chaos rule:
会发生什么情况是IE8会错误地认为这是一个有效的规则,而其他浏览器不会应用,留下一个混乱规则:
.my-dirty-rule-for-ie-8-only { margin-bottom: 5px\0; }
For this ruleset, that means the second padding will take effect by overriding the first one only if the user displays your page with IE8. 对于此规则集,这意味着仅当用户使用IE8显示您的页面时,第二个填充才会通过覆盖第一个填充来生效。
From a developper point of view, css hacks should be avoided at all cost. 从开发者的角度来看,应该不惜一切代价避免使用css hacks。 You seriously never want to deal with rules targeting a specific browser, as it will haunt you forever from the moment you fall for it.
你真的不想处理针对特定浏览器的规则,因为它会从你堕落的那一刻起永远困扰你。
As Harry pointed out, it was a IE specific hack. 正如哈利指出的那样,这是一个IE特定的黑客攻击。 You use the
\\0
part to specify the declaration for a specific IE version. 您使用
\\0
部分指定特定IE版本的声明。 More information about it here: 有关它的更多信息:
http://codemug.com/html/css-hacks-for-ie6ie7ie8ie9-and-ie10/ And here http://mynthon.net/howto/-/webdev/CSS-big-list-of-css-hacks.txt (See: 24. IE9 hack) http://codemug.com/html/css-hacks-for-ie6ie7ie8ie9-and-ie10/这里http://mynthon.net/howto/-/webdev/CSS-big-list-of-css-hacks。 txt (参见:24。IE9 hack)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.