最佳答案
有没有可能,除了我正在做的事情,因为它似乎不起作用,做到这一点?我希望能够拥有一个类下面的子类,以便专门为 class.subclass 使用 CSS。
CSS
.area1
{
border:1px solid black;
}
.area1.item
{
color:red;
}
.area2
{
border:1px solid blue;
}
.area2.item
{
color:blue;
}
超文本标示语言
<div class="area1">
<table>
<tr>
<td class="item">Text Text Text</td>
<td class="item">Text Text Text</td>
</tr>
</table>
</div>
<div class="area2">
<table>
<tr>
<td class="item">Text Text Text</td>
<td class="item">Text Text Text</td>
</tr>
</table>
</div>
So that I can just use class="item" for the elements under the parent css class "area1","area2". I know I can use class="area1 item" to get this to work, but I don't understand why it has to be so verbose about it. Shouldn't the css subclass look at what parent class it is under in order to define it?
注意: 这在 IE 中可以工作(现在使用7) ,但是在 FF 中不能,所以我假设这不是一个 CSS 标准的做事方式。