CSS 的嵌套选择器在 IE8 中不起作用,但在 IE6 中起作用?

发布于 2024-09-14 06:13:04 字数 701 浏览 1 评论 0原文

您好,下面的代码在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

总攻大人 2024-09-21 06:13:04

您的 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'>".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文