DIV宽度不能扩展以适应子DIV的宽度 - IE7

4
我有一个带有ASP.NET Gridview的页面...该Gridview位于父DIV内的子DIV中。该Gridview经常会大于设置的父DIV宽度。在IE6中,MAINDIV(父DIV)会扩展以适应包含在子DIV中的扩展Gridview。在IE7中,DIV不会扩展,因此它会重叠并且看起来很糟糕。我希望MainDiv能够根据子DIV的宽度动态增长,就像在IE6中一样。
请参见下面的代码。我希望MainDiv保持在大约800px左右,除非被推出更远。
谢谢任何有关解决此问题的想法。每当我尝试使用min-width时,它都会将父DIV吹到100%屏幕大小。
<body style="width:100%;text-align:center;background-color:#68838B" onload="loadpage();"> 
  <form id="frmMain" runat="server"> 
    <div id="mainDiv" style="position:relative;top:10px;width:800px;height:auto; background-color:white;border:solid 1px #666666"> 
      <div id="contentDiv" style="text-align:left;width:797px; padding:3px 3px 3px 3px;"> 
        <asp:ContentPlaceHolder ID="contentBody" runat="server">
        </asp:ContentPlaceHolder> 
      </div> 
    </div> 
  </form> 
</body> 

你能贴出你的剩余代码吗? - Scott
<body style="width:100%;text-align:center;background-color:#68838B" onload="loadpage();"> <form id="frmMain" runat="server"> <div id="mainDiv" style="position:relative;top:10px;width:800px;height:auto; background-color:white;border:solid 1px #666666">
<div id="contentDiv" style="text-align:left;width:797px; padding:3px 3px 3px 3px;"> <asp:ContentPlaceHolder ID="contentBody" runat="server"></asp:ContentPlaceHolder> </div> </div> </form> </body> </html>
- Albert
最简单的方法是在这里发布代码?我需要在代码前后使用某种标记吗? - Albert
我猜在评论中你无法格式化文本。 - Kees de Kooter
请编辑您的原始问题并将代码粘贴在那里。每行缩进四个空格。 - Jonathan Fingland
1个回答

1

你告诉它有一个 width:800px,所以它就有了。IE6 错误地将 width 视为 min-width。将你的 IE6 样式移动到单独的样式表中,并使用条件注释来覆盖 min-width(IE6 无法支持)与 width


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接