我有以下HTML标记:
我还有以下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可能会以怪异模式呈现您的页面,这意味着它将像其前辈一样,并将您的.drop.a选择器视为.a.
尝试在页面中添加doctype声明,看看是否可以修复它.如果您的页面上已有一个并且您仍然看到此行为,则其他错误.