我喜歡這些CSS變化(以一種自虐的方式)。我很吃驚想出了一個解決方案:
<html>
<head>
<style type="text/css">
html, body, div { margin: 0; padding: 0; }
#container { width: 600px; height: auto; margin: 0 auto; background: orange; position: relative; }
#left { background: green; width: 300px; }
#right { overflow: auto; background: yellow; width: 300px; position: absolute; top: 0; bottom: 0; right: 0; }
</style>
</head>
<body>
<div id="container">
<div id="left">
<p>f this is not possible, I would settle for this: #container has a fixed height, #b has a fixed height. #a has two block-level elements (#1 and #2) that have uncontrollable heights. #2 should be 100% of #a, minus the height of #1.</p>
<div id="right">
<p>I have a container div (let's call it #container) which contains two divs (#a and #b). I am not in control of the content of these two divs.</p>
<p>I want #container to be the height of #a. I also want #b to stretch (or shrink, depending) to 100% of #container, and have a scrollbar, if necessary.</p>
</div>
</div>
</body>
</html>
試試吧,其中左邊是比對大,它仍然有效。
這可能值得添加一個DOCTYPE來強制IE進入一個稍微不吸引人的模式。
發佈一些代碼或詳細說明您的頁面佈局。 – adatapost 2009-09-05 08:22:40
你的第一個要求是#container是#a的高度,這意味着如果你想顯示#b,總會有一個滾動條,因爲#a需要#container的所有高度 – 2009-09-05 08:29:04
你願意爲幾個JavaScript的行? – 2009-09-05 08:52:52