我知道 IE7 不支持除 direction
和 visibility
之外的任何 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-color
和 display
也会受到影响。
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/