-1

我有一些这样的html:

<table id="MatrixTable" class="zebra-striped">
    <thead>
        <tr style="background-color: White;">
            <td style="min-width: 31px !important;">
                ...
            </td>

如您所见,我在 html 代码中将背景颜色设置为白色。

接下来,如果我在 CSS 中设置它,那么它就不再起作用了。奇怪,因为当我在运行时检查 CSS(IE F12)时,我可以看到 thead / tr 的背景颜色为白色。

#MatrixTable thead tr  
{
    background-color: White !important;
}

为什么这不适用于 CSS 文件?我的 css 文件中的其他内容已正确应用。

谢谢。

4

2 回答 2

1
  1. check if your css-file is included properly
  2. check if there are other styles overriding your tr style
  3. check other (child-) elements (like your td) having styles that could nullify this style.
  4. correct White to white
  5. check the specificity of your selection rules (inline styles have higher priorities!)

sidenote: avoid !important where ever you can, it leads to sloppy style resulting in such problems. It is not meant to be used for these purposes.

于 2012-05-11T09:51:30.377 回答
0

请改用此 CSS 选择器:

#MatrixTable thead tr td {
    background-color: #FFF !important;
}
于 2012-05-11T09:54:50.627 回答