IE 中的 html 表格 thead 和 th 背景

标签 html css internet-explorer background html-table

我有一个 <table><thead><th>标签。

两者都是 <thead><th>标签有背景图片。 <thead> 的背景图片重复和背景图像 <th>位于单元格的左侧。

在 Firefox 中它工作正常但在 IE 中(我的 IE 是版本 7)<thead> 的背景图像不显示。如果我删除 <th> 的背景图片然后是<thead>的背景图片出现。

有什么建议吗?

编辑: 这是我的简化代码:

<table>
   <thead>
     <tr>
       <th>AAAA</th>
       <th>BBBB</th>
       <th>CCCC</th>
     </tr>
   </thead>
   <tbody>
     <tr>
       <td>1111</td>
       <td>1111</td>
       <td>1111</td>
    </tr>
   </tbody>
</table>

<style>
    thead {
      background: url(PATH TO MY IMAGE) repeat-x center /*this image is not displayed in IE*/
    }
    th {
      background: url(PATH TO MY IMAGE) no-repeat left center
    }
</style>

最佳答案

从此question开始并修改答案:

<style>
  table {
    border-collapse: collapse;
    background: url(PATH_TO_THEAD_IMAGE) repeat-x center;
  }
  tbody {
    background: #fff; /* This covers up most of the <table> background */
  }
  th {
    background: url(PATH_TO_TH_IMAGE) no-repeat left center;
  }
</style>

对您可能想要达到的目标给出一个合理的近似值。这在 Firefox 和 IE7 中似乎工作得差不多,不过我没有检查 Opera/Chrome/Safari/IE8。

您应该将这种脏乱七八糟的东西放入特定于 IE7 的样式表中,并使用特定于 IE7 的条件注释加载它,这样您就不会在 CSS 中乱扔 IE7 乱七八糟的东西。

关于IE 中的 html 表格 thead 和 th 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4171082/

相关文章:

javascript - 为什么 IE 无法加载某些图像?

css - GWT : Internet Explorer transparency issue

html - Internet Explorer 使用错误的屏幕宽度进行 Bootstrap

javascript - 使整个列消失

html - 为什么这些 div 消失了?

html - Bootstrap 4 分页缩放/响应能力

javascript - Twitter 框嵌入?

jquery - 如何表示数学符号并捕获相同的用户输入

css - 不带空格 "a>b"和带空格 "a > b"的 CSS 子选择器有什么区别?

html - 响应式网页设计,它是如何工作的?