CSS填充速记声明中的反斜杠 [英] Backslash in CSS padding shorthand declaration

查看:66
本文介绍了CSS填充速记声明中的反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网站Qq.com有一个规则集,其中包含两个填充声明,这似乎有些奇怪.我的问题是, 11px \ 0 部分有什么作用?这与覆盖第一个填充声明有关吗?我了解在以下情况下使用斜杠的情况:CSS样式中的/(正斜杠)声明,但我从未见过这样的事情.

The website Qq.com has a rule-set with two padding declarations which seem a bit strange. My question is, what does the 11px\0 part do? 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.

.suggestion .s_title {
padding: 3px 0 1px 11px;
padding: 4px 0 1px 11px\0;
color: #a0a3a8;
font-size: 12px;
line-height: 18px;
}

推荐答案

反斜杠零"是针对当前规则针对IE8的CSS hack.除非没有其他选择,否则这可能是一件可怕的事情.发生的情况是IE8错误地认为这是要应用的有效规则,而其他浏览器则不会,这会给您带来混乱的规则:

"Backslash zero" is a css hack targeting IE8 for the current rule. 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:

.my-dirty-rule-for-ie-8-only { margin-bottom: 5px\0; }

对于此规则集,这意味着仅当用户使用IE8显示您的页面时,第二个填充才会通过覆盖第一个填充而生效.

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.

从开发者的角度来看,应不惜一切代价避免CSS hacks.您从不认真对待针对特定浏览器的规则,因为从您沉迷于浏览器的那一刻起,它将永远困扰着您.

From a developper point of view, css hacks should be avoided at all cost. 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.

这篇关于CSS填充速记声明中的反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆