开发者

DIV Width Not Expanding To Fit Width Of Child DIVs - IE7

I have a page with an ASP.NET Gridview on it...this Gridview is located in a child DIV inside a parent DIV. That Gridview can often go wider than the parent DIV width set. In IE6 the MAINDIV (Parent DIV) would expand to fit the expanded Gridview contained within the child DIV. In IE7 the DIV will not expand so it overlaps the DIV and looks bad. I want that MainDiv to dynamically grow with the child DIV width, like it did in IE6.

Please see my code below. I want the MainDiv to remain ~800px unless it is pushed out further.

Thanks for any ideas on a fix for this. Whenever I try min-width it just blows the parent DIV out to 100% screen size.

<body style="width:100%;text-align:center;开发者_JAVA百科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> 


You told it to have a width:800px so that's what it has. IE6 incorrectly treated width as min-width. Move your IE6 styles into a seperate stylesheet and use conditional comments to override min-width (which IE6 doesn't support anyway) with width.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜