css - 使用 CSS 在 IE 中显示已经隐藏的表格单元格

标签 css internet-explorer html-table css-tables

当包含的 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 个其他选择:

  1. 嵌套 <span>标记并使用 display: (none|block)取而代之的是 CSS 中的属性。
  2. 使用text-indent: (-9999em|0)将文本推离屏幕。

关于css - 使用 CSS 在 IE 中显示已经隐藏的表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1131118/

相关文章:

jquery - 有没有办法制作穿孔文本?

javascript - 计算数字的开始中间和结束

javascript - 如何在 IE 中上传文件?

javascript - 检测 IE 7 和 8 问题

jquery:如何根据文本输入隐藏表格

css - 选择主包装器

c# - html Head 标记处的 runat ="server"导致 c# 嵌入式代码块无法转换为客户端代码

html - 两个 float 的 div,一个在下面。适用于除 IE 之外的所有浏览器

javascript - 如何通过 JavaScript 获取 html 表格 td 单元格值?

css - 使用 ng-if 和 ng-style 根据条件更改表格单元格文本颜色