2011-12-28 107 views
0

下面的代码不工作在IE工作。尽管事实上它设置为left:0pxright:0px,但DIV并未跨越整个页面。根据调试器,Body元素有很大的宽度。DIV绝对定位不IE

为什么?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
<head> 
    <title></title> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
</head> 
<body> 
    <div align="center" style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; background-color: red"> 
      Some text 

    </div> 
</body> 
</html> 
+0

哇。你为什么这么做?只需将您的身体bg设置为红色即可。大声笑 – 2011-12-28 08:20:26

+0

这是真正的任务提取。 – Dims 2011-12-28 08:24:50

回答

0

如果你想使用整个页面。使用width:100%height:100%

0

哟不能使用“left:0; right:0;”左边或右边,并在同一容器中与顶部相同。

使用此

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
<head> 
    <title></title> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
</head> 
    <body> 
    <div align="center" style="position: absolute; left: 0; top: 0; background-color: red"> 
     Some text 

    </div> 
</body> 
</html> 
+2

这是错误的。您可以同时使用左侧和右侧,以及顶部和底部。这也只会包含在容器中的内容。测试你的代码,然后再做出这样的陈述。 – 2011-12-28 08:25:30

+0

你为什么说IE可以同时使用'left'和'right'而IE不能使用它? – Dims 2011-12-28 08:30:16

+0

没有必要要摆正和在同一个容器中离开。如果我会用左,右同一个容器中最后一个覆盖第一个,为什么我说你不能在同一个容器中的左侧和右侧。 – 2011-12-28 08:31:20

0

其实,不需要利润。它也在IE中工作!

position: absolute; width:100%;height:100%;background-color: red; 
+0

那么,'right'在IE中不能正常工作? – Dims 2011-12-28 08:25:19