答案 0 :(得分:1)
这似乎有效。在调整窗口大小时,元素也会调整大小,以便只有在没有足够空间显示所有内容时才能滚动。
setWindowHeight();
function setWindowHeight() {
var windowHeight = window.innerHeight;
document.body.style.height = windowHeight + "px";
}
window.addEventListener("resize", setWindowHeight, false);
.float {
float: left;
width: 33%;
height: 100%;
}
.left {
background: #f00;
}
.center {
background: #0f0;
}
.right {
background: #00f;
}
.scrollable {
height: 100%;
overflow-y: scroll;
}
<body>
<div class="float left">
Left
</div>
<div class="float center">
<div>
Center
</div>
<div class="scrollable">
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
<p>Scrollable</p>
</div>
</div>
<div class="float right">
Right
</div>
</body>