画面の残りの部分を占めるiframeの上に任意のコンテンツを含むヘッダーを表示したい。私はこれをテーブルで動作させることができました:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
html, body, iframe, table, tr, td {
margin: 0; padding: 0;
}
html, body, iframe, table, #content {
height: 100%; width: 100%;
}
table {
border-collapse: collapse;
}
iframe {
border: 0;
}
</style>
</head>
<body>
<table>
<tr><td>
<div id="header">
<p>some arbitrary stuff in a header</p>
<p>this is sized dynamically</p>
<p>it's not a fixed size</p>
</div>
</td></tr>
<tr><td id="content">
<iframe src="http://www.bing.com/search?q=stackoverflow" />
</td></tr>
</table>
</body>
</html>
これはFirefoxとChromeで機能しますが、IE7では機能しません(理由はわかりません)。テーブルを使用せずに、これは私が得ることができる最も近いものです:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
html, body {
margin: 0; padding: 0;
height: 100%;
}
iframe {
margin: 0; padding: 0;
width: 100%;
border: 0;
}
</style>
</head>
<body>
<div id="header">
<p>some arbitrary stuff in a header</p>
<p>this is sized dynamically</p>
<p>it's not a fixed size</p>
</div>
<iframe src="http://www.bing.com/search?q=stackoverflow" />
</body>
</html>
これはすべてのブラウザで同じように見えますが、iframeが短すぎます。ただし、高さを100%に設定すると、画面と同じ大きさになり、2つのスクロールバーが表示されます(テーブルバージョンのIE7と同じ)。ブラウザウィンドウに残っているスペースをiframeが占有するようにしたいのですが、それ以上は占有しません。私はむしろJavascriptに頼る必要はありません。