css - IE7 和 "inherit": ignoring entire rule?

标签 css internet-explorer-7

我知道 IE7 不支持除 directionvisibility 之外的任何 CSS 属性的值 inherit。当浏览器不支持某个值时,它不应该应用给定的声明(该特定行)。有谁知道为什么 IE7 不使用第一个 ul a 颜色声明,而是选择使用普通的 a 颜色声明?它只是忽略了整个 ul a 规则吗?

要清楚:在大多数浏览器中,第一个链接是红色的,第二个链接是蓝色的。在 IE7 中,第一个链接是红色的,但第二个也是红色的,即使我至少有一个声明它应该在 ul a 规则中理解。

<!DOCTYPE html>
<html>
<head>
    <title>Anchor Inherit Test</title>
    <style type="text/css">
    body {
        color: #369;
    }
    a {
        color: #f00;
    }
    ul a {
        color: #369;
        color: inherit; /* this should be ignored by IE7, right? */
    }
    </style>
</head>
<body>
    <p>This is testing a <a href="#">red link</a> in a paragraph.</p>

    <ul>
        <li><a href="#">here is a link that should not be red</a></li>
    </ul>
</body>
</html>

最佳答案

color 不是唯一不会忽略不受支持和无效值的属性。
例如 background-colordisplay 也会受到影响。

Does anyone know why IE7 doesn't use the first ul a color declaration, instead choosing to use the plain a color declaration? Is it just ignoring the entire ul a rule?

任何无法识别的值(甚至没有)都会触发错误。
显然,如果最后一个包含错误值,LTE IE7 会丢弃所有颜色声明在同一规则中(甚至是 !important)。
还有这个jsbin确认它也有效地覆盖了同一规则中的先前声明。

作为替代方案,您可以使用 dynamic property .

关于css - IE7 和 "inherit": ignoring entire rule?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4148614/

相关文章:

javascript - Foundation 5 清除灯箱不适用于 angularjs 动态图像

html - 调整内容 : space-between not applying on nested flex box

javascript - 如何为任何 html 标签分配一个类名?

html - CSS 代码仅在网站上线时不起作用

html - 删除 Bootstrap 表单输入之间的边距

html - IE7 对齐表格单元格中按钮旁边的文本

css - MS IE 7 中的圆 Angular

html - 为 Internet Explorer 设计 hr

CSS 背景图片在 IE6 和 IE7 中不一致

javascript - IE9 默认为 IE7,javascript 错误