1

我有一些在 Internet Explorer 6 中不起作用的非常简单的 HTML 和 CSS。

<!DOCTYPE HTML>
<html>
    <head>
        <style>        
            table td.one.read {background-color:#FFD700;}
            table td.two.read {background-color:#0000ff;}
            table td.three.read {background-color:#ff8c00;}
        </style>
    </head>

    <body>
        <table>
            <tr class="head">
                <td></td>
                <td class='one read'>one</td>
                <td class='two read'>two</td>
                <td class='three read'>three</td>
            </tr>

            <tr>
                <td>Legend</td>
                <td class='one read'>1</td>
                <td class='two read'>2</td>
                <td class='three read'>3</td>
            </tr>
        </table>
    </body>
</html>

一个简单的表格,每列都有不同的背景颜色。为了简单起见,我删除了一堆其他 CSS/HTML。问题是所有列在 Internet Explorer 6 中显示为相同的橙色,在Firefox中运行良好。

我怎样才能让它工作?

4

2 回答 2

5

这是 IE6 中的一个错误。

如果您有一个具有多个类名的 CSS 选择器(例如,.three.read),IE6 将忽略除最后一个之外的所有类名。

因此,IE6 看到选择器的三个 CSS 规则table td.read

为了解决这个问题,您可以组合您的课程。(例如,<td class='OneRead'>table td.OneRead {background-color:#FFD700;}

于 2010-01-06T16:22:36.207 回答
1

IE6 不支持多个类,必须再等几年才能 IE6 死掉。不过现在,您可以为颜色创建单独的类。

于 2010-01-06T16:41:35.490 回答