87,989
社区成员
发帖
与我相关
我的任务
分享
body{ height:100%}
.content{height:100%;overflow:auto}
<script type="text/javascript">
function windowHeight() {
var de = document.documentElement;
return self.innerHeight||(de && de.clientHeight)||document.body.clientHeight;
}
window.onload=window.onresize=function(){
var hh=document.getElementById('content').offsetHeight;
var wh=windowHeight();
if(hh<wh){
document.getElementById('content').style.height=wh;
}
else{
document.getElementById('content').style.height='auto';
}
}
</script>
body{ height:100%}
<div id="content"></div>
<script>
var content = document.getElementById('content');
content.style['min=height'] = document.body.clientHeight;
content.style.overflow = 'auto';
</script>