不好意思問這個問題,因爲這裏有很多CSS 100%高度問題(我讀過)。使用100%高度的CSS實現簡單的行佈局
我要使用DIV而不是TABLE來實現簡單的佈局。前3行是固定高度,第4行應擴展,第5行應爲固定大小(在底部)。
這是一個表,我怎麼能用DIV做到這一點?
這裏的表版本:
<html>
<head>
</head>
<body>
<table width="100%" height="100%" border="1">
<tr height="20px">
<td>
fixed height 20
</td>
</tr>
<tr height="50px">
<td>
fixed height 50
</td>
</tr>
<tr height="100px">
<td>
fixed height 100
</td>
</tr>
<tr>
<td>
auto expanding height
</td>
</tr>
<tr height="50px">
<td>
fixed height 50
</td>
</tr>
</table>
</body>
</html>
這裏是到目前爲止它不工作,我的最好的嘗試。
<html>
<head>
</head>
<body>
<div style="width: 100%; height: 100%; border-width: 2px; border-style: solid;">
<div style="height: 20px; border-width: 2px; border-style: solid">
fixed height 20
</div>
<div style="height: 50px; border-width: 2px; border-style: solid">
fixed height 50
</div>
<div style="height: 100px; border-width: 2px; border-style: solid">
fixed height 100
</div>
<div style="border-width: 2px; border-style: solid;">
Auto expanding?
</div>
<div style="height: 50px; border-width: 2px; border-style: solid">
fixed height 50
</div>
</div>
</body>
</html>
您是否嘗試添加文檔類型?例如:<!DOCTYPE html> – 2012-01-11 15:07:06
你的例子似乎工作http://jsfiddle.net/zDLGM/你的意思是你想要第三行擴大,使整個事情填充頁面? – lupos 2012-01-11 15:07:23
是的。就像桌子一樣。 – sproketboy 2012-01-11 15:14:51