我在IE7中渲染时遇到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>
</head>
<body>
<div id="floating" style="float: right; background-color: #ccf">
This is the top right links block
</div>
<div id="body" style="width: 800px; margin: auto; background-color: #fcc">
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
</div>
</body>
IE7中此代码的问题:
我在IE7中得到的结果:
正确的显示将是(div&#34; body&#34;居中):
我在IE7中得到的结果:
正确显示:
有没有人遇到过这种问题?
是否有任何提示在IE7上正确使用?
谢谢
答案 0 :(得分:0)
将两个div包含在包含div中。给包装纸宽度:100%;或者你想要的总宽度。所以你的代码应该是这样的:
<!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>
</head>
<body>
<div id="wrapper" style="width: 100%;">
<div id="body" style="width: 800px; margin: auto; background-color: #fcc">
/*---- Moved element ---- */
<div id="floating" style="float: right; background-color: #ccf">
This is the top right links block
</div>
/*---- End Moved element ---- */
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
This is the body.
</div>
</div>
</body>
</html>
我真的不明白它,但你可以将它包装在div中,或者给body标签宽度为100%或任何你想要的大小。无论如何,给身体标签宽度为100%通常是好的,并设置一个包装div来设置盒子的宽度。