简体   繁体   English

CSS填充速记声明中的反斜杠

[英]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.

相关问题 CSS 填充速记与 4 行代码的问题 - CSS problem with padding shorthand vs 4 line code 带空格的CSS速记属性 - CSS shorthand attribute with gaps CSS的速记性质和方法 - shorthand properties and method of css <span>/</span><div> css 的简写 - 这是合法的吗?</div><div id="text_translate"><p> 如果我创建一个 HTML 元素:</p><pre class="lang-css prettyprint-override"> sc { font-variant: small-caps; }</pre><p> 并像这样应用它:</p><pre class="lang-html prettyprint-override"> I want to display &lt;sc&gt;this text&lt;/sc&gt; in small-caps.</pre><p> 它按预期工作(当然,在 IE 中除外。)它成为简写</p><pre class="lang-css prettyprint-override">.sc { font-variant: small-caps; }</pre><pre class="lang-html prettyprint-override"> I want to display &lt;span class='sc'&gt;this text&lt;/span&gt; in small-caps.</pre><p> 这是预期/记录的行为吗? 它有名字吗?</p></div> - <span>/<div> shorthand for css - is this legit? 字体速记的奇怪CSS行为 - Strange CSS behaviour with font shorthand CSS3中的背景速记顺序 - background shorthand order in CSS3 html电子邮件的速记CSS可能吗? - Shorthand CSS on html emails possible? CSS是否有更好的border速记版本? - CSS is there a better shorthand version for border? 将 CSS 背景速记转换为速记 - Convert CSS background shorthand to longhand CSS填充问题,填充不起作用 - CSS padding issue, padding not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM