设置div 自适应高度和宽度1

<div  id="show" style="overflow:auto;">

</div>

<script language="javascript">

var h=document.body.offsetHeight-85;//计算需要自适应窗口的高度( 窗口高度减去其他窗口的高度)
var w=document.body.offsetWidth;
document.getElementById("show").style.width=w;
document.getElementById("show").style.height=h;
$(window).resize(function(){
var h=document.body.offsetHeight-85;
var w=document.body.offsetWidth;
document.getElementById("show").style.width=w;
document.getElementById("show").style.height=h;
});

</script>

 

posted @ 2013-04-28 16:14  Optimal New  阅读(375)  评论(0编辑  收藏  举报