1、头部定义一个div,固定高度,设置绝对定位(position:absolute),设置上边距(top:0);
2、底部定义一个div,固定高度,设置绝对定位(position:absolute),设置下边距(bottom:0);
3、中间定义一个div,设置滚动条自动( overflow: auto); 设置绝对定位(position:absolute),设置top和bottom,top的值等于头部div的高度,bottom的值等于底部div的高度
示例
htmlhead meta http-equiv=Content-type content=text/html; charset=UTF-8 / title/title style #page{margin:0 auto;width:960px;} #header{width:960px; height:60px; position:absolute; top:0;background-color:#ccc;} #footer{width:960px; height:30px; position:absolute; bottom:0; background-color:#ccc;} #content{width:960px; overflow: auto; position:absolute; top:60px; bottom:30px;} /style/headbodydiv id=page div id=header定义顶部/div div id=contentcontent定义中间/div div id=footerfooter定义底部/div/div/body/html
取消
评论