您应该使用稍微不同的 HTML 部分结构来获得所需的结果。我面临同样的问题,我使用了如下所述的解决方案:
http://jsfiddle.net/92y9L/
相关代码:
CSS
*{
margin:0;
border:0;
padding:0;
}
.outer
{
position:relative;
width:250px;
height:350px;
border:1px dotted black;
margin:-1px;
}
.tbl
{
display:table;
width:100%;
height:100%;
}
.tr
{
display:table-row;
}
.td
{
display:table-cell;
margin:0 auto;
text-align:center;
}
.tr .body-outer
{
height:100%;
width:100%;
}
.body-outer
{
position:relative;
}
.body-inner
{
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
overflow-y:auto;
overflow-x:auto;
}
.stretch-x
{
width:100%;
}
.stretch-y
{
height:100%;
}
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<body>
<div class="outer">
<div class="tbl">
<div class="tr" style="background-color:Red;">
<p>test paragraph. This is used as placeholder<br />new line....</p>
</div>
<div class="tr stretch-y" style="background-color:Gray;">
<div class="td stretch-y" style="background-color:Blue;">
<div class="body-outer" style="background-color:Green;">
<div class="body-inner">
<p style=" white-space:nowrap;">test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
<p>test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
<p>test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
<p>test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
<p>test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
<p>test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
<p>test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
<p>test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
<p>test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
<p>test paragraph. This is used as placeholder<br />new line....</p>
<p>test paragraph. This is used as placeholder</p>
</div>
</div>
</div>
</div>
<div class="tr" style="background-color:Red;">
<p>test paragraph. This is used as placeholder<br />new line.</p>
</div>
</div>
</div>
</body>
这种方法的概念是使用一个内部 css 表,在外部容器的边界下具有三个 css 表行。上面的 CSS 行用于托管页眉,较低的 CSS 行用于托管页脚。它们都根据其内容自动调整大小。
中间一行作为body容器,通过设置高度为100%进行拉伸。关于“body”css 行的内部内容,已使用外部相对/内部绝对布局技术,以强制内容适合“body”css 行的边界内并允许溢出。IE需要中间css表格单元格才能满足拉伸的要求。
这种设计与 FF+Chrome+Opera+Safari 完美配合,但 IE 拒绝计算“body”内容相对于其祖先 CSS 表格行的高度,并且坚持将其与外部 div 的高度相关联。这正是我面临的问题。
总之,如果 IE 移动正文内容没有问题,这个解决方案可能对您有用。