当包含的 div 的类更改为“b”时,IE 7 不显示最初隐藏的表格单元格 (class="c"),其中删除了“display:none”规则。但是,它应该像它对行 (class="r") 所做的那样。其他浏览器行为正常。似乎是一个 IE 错误。以前有人遇到过这个问题吗?有什么解决办法吗?
<html>
<head><style type="text/css">
.a .c { display: none; }
.a .r { display: none; }
.b .c { display: block; } /*Edited after comments, still not working*/
.b .r { display: block; } /*Edited after comments, still not working*/
</style></head><body>
<div class="a">
<table>
<tr>
<td>11</td>
<td class="c">12</td>
<td>13</td>
</tr>
<tr>
<td>21</td>
<td class="c">22</td>
<td>23</td>
</tr>
<tr class="r">
<td>31</td>
<td class="c">32</td>
<td>33</td>
</tr>
</table>
</div><button onclick="document.getElementsByTagName('div')[0].className = 'b'">Change class</button></body></html>
PS:我正在尝试找到一个纯 CSS 解决方案。
最佳答案
您需要使用 display: table-cell;
或 display: table-row;
在你单独的类里面,为你的<td>
和 <tr>
分别标记。
这在 IE6/7 中不起作用,因此还有 2 个其他选择:
- 嵌套
<span>
标记并使用display: (none|block)
取而代之的是 CSS 中的属性。 - 使用
text-indent: (-9999em|0)
将文本推离屏幕。
关于css - 使用 CSS 在 IE 中显示已经隐藏的表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1131118/