IE和绝对定位div

时间:2009-12-28 05:11:58

标签: css internet-explorer position absolute

此问题仅在IE中出现。请考虑以下HTML:

 <html>
 <body>
 <div style='position:absolute;left:1em;right:1em;top:1em;bottom:1em;overflow:auto;>
 Put more than a full screen of text in here.  It *should* create a scroll inside the div.
 In IE, it stretches the div out vertically.
 <div>
 <body>
 <html>

如果你在div中放入大量文本,IE会将div拉伸到声明的“bottom”之外。我知道它在做什么。在渲染完所有文本后,它会将页面底部视为页面底部。我想底部是可见窗口的底部。所以,我希望有一个在窗口中心的div。是否有一些迟钝的黑客让IE理解CSS的基本概念?

3 个答案:

答案 0 :(得分:1)

使用conflicting absolute positions时,请不要忘记在该文章的“为IE5和IE6创建例外”标题下修复IE6。

答案 1 :(得分:0)

body: 100%;

div#id height: 100%;

答案 2 :(得分:0)

您可以尝试使用条件注释仅为IE添加overflow:auto;

相关问题