如何在表格单元格内垂直拉伸DIV?
我想height: 100%
将被罚款
但在某些情况下 - 它不是(至少在IE8)在表格单元格内垂直拉伸div - IE8
这里是一个简单的例子:
3行的表,用标题,内容,和页脚;
我希望'content'单元格中的'content'DIV垂直拉伸100%; 它在FF和铬,但不是在IE8
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<div style="overflow: auto; height: 20em; width: 20em;">
<table style="height: 100%; width: 100%;">
<tr style="background-color: blue;">
<td>
<div>header</div>
</td>
</tr>
<tr style="height: 100%;">
<td style="background-color: yellow;">
<div style="height: 100%; background-color: red; overflow-y: scroll;">
content
</div>
</td>
</tr>
<tr style="background-color: blue;">
<td>
<div>footer</div>
</td>
</tr>
</table>
</div>
任何人都可以提出一个解决方案,这个简单的问题? 它在IE8,FF任何Chrome工作(IE7及以上并不重要)
,它必须是基于CSS(不需要JavaScript)
请,像“不使用表格排版不建议智慧',因为我可以使用display: table
等DIVs - 问题是相同的(我在例子中使用TABLE,TR,TD,因为它更具可读性)
您的示例代码似乎在IE8中正常工作。 – Faust 2011-04-09 20:52:00
好的,那是因为你在怪癖模式下尝试过......但我需要标准模式(我编辑了示例,并添加了doctype定义) – slobo 2011-04-10 14:54:54