IE9中不可预测的嵌套div水平位置

| 我绝不是HTML或CSS方面的专家,但我通常可以绕开逻辑问题。这让我难过。 我在父div内嵌套了一个div(旨在携带表格)。我将其位置设置为绝对,底部设置为零,以便它出现在父级的底部。然后,我指定了边距以设置我想要的确切的左和底部缩进。 在IE9中预览时,一切正常,但是,当我上传并在线查看后,IE9将嵌套的div渲染到右侧。选择兼容模式可以解决此问题。 现在,我将嵌套的div向左浮动(在父级中),问题得到了解决。除非我选择兼容模式,否则IE9会使它更好。 这是我的CSS:
.wrapper {float:left; width:100%; height:380px;background-image:url(../images/top_bck.png); background-repeat: repeat-x; background-position: top;}

.box {position:absolute; top:40%; left:50%;width:832px; height:553px;   margin:-180px 0 0 -416px;background-image:url(\'../images/back.jpg\'); background-repeat: no-repeat; background-position: bottom;}

.right { position:relative; float:right;width:580px; height:254px; text-align: left;padding:10px; margin-top:183px;}

.form {position:absolute;bottom:0; float:left; width:400px; padding:0px 0px 0px 36px; display:block; margin-bottom:4px;  }
我猜测问题是类之间的关系之一,但我确定找不到。任何帮助都将得到极大的帮助。 这是HTML
<!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=UTF-8\" />
<title>Site Coming Soon :: Company :: Company Description</title>
<link rel=\"shortcut icon\" href=\"favicon.ico\" />
<!-- Loads Master CSS -->
<link rel=\"stylesheet\" href=\"css/style.css\" type=\"text/css\" media=\"screen, projection\" />
</head>
<body>
<div class=\"wrapper\">


<div class=\"box\">
    <div class=\"content\">



        <div class=\"right\">
                <h2>Site coming soon.</h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
                <h3>Sed diam nonummy.</h3>Sed diam nonummy. Nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad.
                <h3>Be informed:</h3>Enter your email address below and be notfied as soon as our site goes live.
                <div class=\"form\">
                    <form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
                        <label>
                            <input type=\"text\" name=\"emailForm\" id=\"emailForm\" />
                        </label>
                        <label>
                            <input type=\"submit\" name=\"submitButton\" id=\"submitButton\" value=\"notify me\" />
                         </label>
                    </form>
                </div>
        </div>
    </div>

</div>
<div class=\"footer\">
    &copy; Company Ltd 2011. Company registered in England and Wales. Registered Company Number 0000000. 
</div>
</div>
</body>
</html>
    
已邀请:
在查看CSS时,我发现一个很好的比喻是纸箱,这意味着您从一个纸箱开始,然后将其他纸箱放在大纸箱中。如果预期的“内部”框太大,则它们会破坏第一个框,并且所有内容都从框中掉出来。 因此,我的第一个观察结果是将包装器的高度设置为380px,其中当框为553px时,这将立即破坏框。 现在,我们进入问题的症结所在,即您对包装器浮动的CSS定位的了解,我想期望其中的所有内容都将落入该包装器中。 然后,您开始定位绝对元素,这实际上消除了相对于您向左浮动的包装器的定位控制,现在相对于屏幕的左上角(尽管这并不完全是正确的)每种情况)。 您需要通过固定框模型并允许您的版权的位置相对于HTML中其旁边的框相对,将其位置更改为相对位置并从包装器中移除高度。 希望这可以帮助     

要回复问题请先登录注册