CSS规则“.drop.a”应用于类别“拖动” [英] CSS rule ".drop.a" being applied to class "drag a"
问题描述
我有以下HTML标记:
I have the following HTML markup:
<div class="drag a"></div>
<div class="drop a"></div>
我也有以下CSS规则,应该只应用于我的第二个div:
I also have the following CSS rule, which should only be applied to my 2nd div:
.drop.a
{
background-color:red;
}
这是正常工作,除了在Internet Explorer 9的CSS规则正在应用
This is working fine, except in Internet Explorer 9 the CSS rule is being applied to both elements.
为什么是这样?我认为这种CSS是普遍兼容所有的浏览器?
Why is this? I thought this kind of CSS was universally compatible with all browsers?
推荐答案
CSS与所有浏览器通用兼容?
I thought this kind of CSS was universally compatible with all browsers?
不适用。 IE(直到并包括版本6)忽略链中除最后一个之外的所有类选择器。 IE9可能会在您的网页quirks模式,这意味着它会像其前身一样,将 .drop.a
选择器视为 .a
。
Nope. IE up to and including version 6 ignores all class selectors in a chain except the last one. IE9 may be rendering your page in quirks mode, meaning it'll act like its predecessors, and treat your .drop.a
selector as .a
instead.
尝试在页面中添加一个doctype声明,看看是否可以修复它。如果您的信息页上已有某个信息,但您仍然看到此行为,则会出现其他错误。
Try adding a doctype declaration to your page and see if that fixes it. If you already have one on your page and you're still seeing this behavior, something else is wrong.
这篇关于CSS规则“.drop.a”应用于类别“拖动”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!