读书人

div 横向格局 中间高度自适应

发布时间: 2012-12-03 13:48:35 作者: rapoo

div 横向布局 中间高度自适应

<html>
<div id="header" style="height:100px; background-color:red"></div>
<div id="content" style="overflow-y:auto; background-color: yellow">会自动出现滚动条</div>
<div id="footer" style="height:100px; background-color:blue"></div>
<script type="text/javascript">
function resizeContent(){
??? availHeight = parseInt(document.body.clientHeight);
??? header_height=parseInt(document.getElementById("header").style.height);
??? footer_height=parseInt(document.getElementById("footer").style.height);
??? content_height=(availHeight-header_height-footer_height)+"px";
??? document.getElementById("content").style.height=content_height;
}
resizeContent();
window.onresize=resizeContent;
</script>
</html>

读书人网 >行业软件

热点推荐