css - IE CSS 错误 : table border showing div with visibility: hidden, position:absolute

标签 css internet-explorer

问题

我有一个 <div>在最初用 visibility: hidden; position: absolute 隐藏的页面上.问题是如果 <div>以这种方式隐藏包含一个使用 border-collapse: collapse 的表并在其单元格上设置了边框,该边框仍然显示“穿过”隐藏的 <div>在 IE 上。

通过在 IE6 或 IE7 上运行下面的代码来亲自尝试一下。你应该得到一个白页,但你会看到:

alt text http://img.skitch.com/20090110-enuxpb5aduqceush46dyuf4wk7.png

可能的解决方法

由于这是在 IE 上发生的,而不是在其他浏览器上发生的,因此我认为这是一个 IE 错误。一种解决方法是添加以下代码来覆盖边框:

.hide table tr td {
    border: none;
}

我在想:

  • 这是一个已知的 IE 错误吗?
  • 是否有更优雅的解决方案/解决方法?

代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <style type="text/css">

            /* Style for tables */
            .table tr td {
                border: 1px solid gray;
            }
            .table {
                border-collapse: collapse;
            }

            /* Class used to hide a section */
            .hide {
                visibility: hidden;
                position: absolute;
            }

        </style>
    </head>
    <body>
        <div class="hide">
            <table class="table">
                <tr>
                    <td>Gaga</td>
                </tr>
            </table>
        </div>
    </body>
</html>

最佳答案

这是一个 IE 错误。 Firefox 无法识别使用“border-spacing”的“border-collapse”,这不会导致此问题。使用“display:none”的解决方案有效,但还有另一种可能性。如果可见性属性是使用 Javascript 设置的,那么边框也会被隐藏(正如预期的那样)。

关于css - IE CSS 错误 : table border showing div with visibility: hidden, position:absolute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/430485/

相关文章:

html - 如何使用 CSS 创建向下箭头?

c# - 基于枚举值的样式

html - 全宽背景视频作为 IE 中的横幅?

wpf - 在 Internet Explorer 中运行的 MFC ActiveX 中承载的 wpf 窗口中的击键

css - 如何在通过 ajax 加载时覆盖 <tr> 的 CSS?

html - 为什么悬停输入会在 CSS 中的相应标签上触发?

html - 为什么 float 元素不能设置左右外边距

javascript - 在 ie8 中使用 jasmine 比较数组失败

Safari 和 IE 中的 CSS 问题

javascript - Chrome 和 IE 自动对 JSON 对象进行排序,如何禁用它?