类中的类,ie6中的bug

时间:2012-12-18 18:03:03

标签: html css class internet-explorer-6

我正在编写HTML / css代码并在IE6中有一个特定的错误。

我想使用类创建可更改的div:

例如(这只是示例,而不是真实的项目代码)

.top {width: 50px;}
.top.selected {background: #f00;}
.mid {width: 114px;}
.mid.selected {background: #0f0;}
.bot {width: 100px;}
.bot.selected {background: #0ff; color: #f00;}
...etc...

所以,html就像一个:

<div class='top selected'>1</div>
<div class='mid'>2</div>
<div class='bot selected'>3</div>

这对程序员来说会很棒,但它在IE6中不起作用:(

.topselected {background: #f00;} // <div class='top topselected'> ,但它真的很脏代码......也许有些东西有些黑客?

1 个答案:

答案 0 :(得分:0)

似乎这里的方法是创建更多的语义类名,然后将其拆分出来:

.highlighted { background: #0f0; }
.wide { width: 114px; }
/* etc... */

然后你的html将运行良好,IMO,更易于维护。