61,112
社区成员
发帖
与我相关
我的任务
分享
<style>
body {margin:0;padding:0}
#main {background:yellow;height:100%;width:100%}
#bt {background:red;height:200px;position:absolute;bottom:0px;left:0px;width:100%;}
</style>
<div id="main">top</div>
<div id="bt">foot</div>
<body>
<form id="form1" runat="server">
<div id="div-up" class="up">
</div>
<div class="down">
</div>
</form>
</body>
<script type="text/javascript">
function changeHeight() {
document.getElementById("div-up").style.height = document.documentElement.clientHeight - 210 + "px";
}
window.onresize = function() {
changeHeight();
};
</script>
.up{width:900px;background-color: Blue; }
.down{width:900px; background-color: Red; height:200px;position:fixed; bottom:0px;}
index_bdTemplate('#bdTemplate');//#bdTemplate是要变化的DIV
function index_bdTemplate(ElementId){
var bodyHeight=$(window).height();//BODY高度
var xx=150;//这是值自己调整
var DIVheight=bodyHeight-xx;
$(ElementId).css({height:DIVheight});//设置元素初始高度
$(window).resize(function(){//浏览器变化时触发事件
var bodyHeightNew=$(window).height();//这是重新获得浏览器BODY高度
var DIVheightNew=bodyHeightNew-xx;
$(ElementId).css({height:DIVheightNew});
});
}