CSS 的嵌套选择器在 IE8 中不起作用,但在 IE6 中起作用?
您好,下面的代码在 IE6 中工作正常,但在 IE8 中不行,我可以知道是什么导致了问题吗?
<html>
<head>
<style type="text/css">
.dataSection {
font-weight:bold;
color:#fff;font-family:Verdana, Arial, Helvetica;
text-align:left;
background-color:#004E82;
padding:2px 4px 2px 2px;
}
.dataSection.header {
font-weight:bold;
color:#fff;
font-family:Verdana, Arial, Helvetica;
text-align:left;
background-color:#004E82;
padding:2px 4px 2px 2px;
}
</style>
</head>
<body>
<table class="DataSection">
<tr>
<td class="header">Summary</td>
</tr>
</table>
</body>
</html>
Hi The below code works fine in IE6 but not in IE8 may i know what is causing the problem ?
<html>
<head>
<style type="text/css">
.dataSection {
font-weight:bold;
color:#fff;font-family:Verdana, Arial, Helvetica;
text-align:left;
background-color:#004E82;
padding:2px 4px 2px 2px;
}
.dataSection.header {
font-weight:bold;
color:#fff;
font-family:Verdana, Arial, Helvetica;
text-align:left;
background-color:#004E82;
padding:2px 4px 2px 2px;
}
</style>
</head>
<body>
<table class="DataSection">
<tr>
<td class="header">Summary</td>
</tr>
</table>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 CSS 是错误的,它似乎在 Internet Explorer 6 中工作,因为它有一个错误,它将
.foo.bar
视为.bar
您正在寻找
.foo .bar
。即“具有类 bar 的元素是具有类 foo 的元素的后代”,而不是您所拥有的“具有类 foo 和 bar 的元素,例如”。
Your CSS is wrong, it just seems to work in Internet Explorer 6 because it has a bug whereby it treats
.foo.bar
as.bar
You are looking for
.foo .bar
. i.e. "An element with class bar that is a descendent of an element with class foo" as opposed to what you have, which is "An element with both class foo and bar such as<div class='foo bar'>
".