代码之家  ›  专栏  ›  技术社区  ›  Funka

这个IE CSS错误叫什么(双垂直填充)

  •  4
  • Funka  · 技术社区  · 16 年前

    编辑: 我已将其放在以下URL: http://jsbin.com/efele
    在IE中打开,在FF中再次打开。比较一下。

    我的问题是:这个bug叫什么(我在什么地方错过了这个?它在你的电脑上找到了吗 this page

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>IE bork!</title>
    <style type="text/css">
    html, body {
     margin:0;
     padding:0;
    }
    #container {
     border:1px solid red;
     background-color:#CC99CC;
     width:800px;
     margin:0 auto;
     padding-top:100px;
    }
    #sidebar {
     float:left;
     display:inline;
     width:200px;
     border:1px solid blue;
     background-color:#00CCFF;
    }
    #content {
     float:right;
     display:inline;
     width:510px;
     border:1px solid green;
     background-color:#66CC99;
    }
    .clear {
     clear:both;
     /* height:0px; <<< setting height seems to be the only thing that makes this work as expected?!? */
     background-color:#CCCCCC; /* bg color here is just for debugging */
    }
    </style>
    </head>
    <body>
    <div id="container">
        <div id="sidebar">I am the sidebar</div>
        <div id="content">I am the content</div>
        <div class="clear"><!-- clear! --></div>
    </div>
    <p>There should be 100px of space above the two floats, but <em>no</em> space below them...</p>
    </body>
    </html>
    

    顺便说一句,我终于找到了安抚IE的办法。解决方案(在我的“clear”div上显式设置一个高度)被注释掉,以显示bug。我只希望我能回到我生命的最后几个小时,那是我偶然发现了真正的问题/解决方案!

    2 回复  |  直到 16 年前
        1
  •  3
  •   JasonWyatt    16 年前

    考虑到你找到的解决方案,它似乎是 hasLayout 怪癖( 明确设置清除div集的高度 hasLayout 到 true )

        2
  •  2
  •   Brian Moeskau    16 年前

    另一方面,如果由于某种原因指定高度不起作用,我经常发现包括 zoom:1; 我需要在IE中触发的任何时候都是救命恩人。每当我在IE中遇到这些奇怪的布局问题时,我总是先尝试看看是否是布局刷新问题(然后,如果这不起作用,继续用头撞键盘)