我有以下 HTML 标记:
<div class="drag a"></div>
<div class="drop a"></div>
我还有以下 CSS 规则,它应该只应用于我的第二个 div:
.drop.a
{
background-color:red;
}
这工作正常,除了在 Internet Explorer 9 中,CSS 规则被应用到两个元素。
这是为什么?我以为这种 CSS 普遍兼容所有浏览器?
最佳答案
I thought this kind of CSS was universally compatible with all browsers?
没有。 IE up to and including version 6 ignores all class selectors in a chain except the last one. IE9 可能会以 quirks 模式呈现您的页面,这意味着它会像它的前辈一样,并将您的 .drop.a
选择器视为 .a
。
尝试向您的页面添加文档类型声明,看看是否可以解决问题。如果您的页面上已经有一个,但您仍然看到这种行为,则说明有其他问题。
关于CSS 规则 ".drop.a"应用于类 "drag a",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10124254/