【发布时间】:2014-05-13 22:49:28
【问题描述】:
基本上我的页面由
组成a) 一个主 div,#main b)标题,#header c) 一个 div,#contain d) 页脚,#footer
页面内容进入contain div。
代码:
#main{
position: absolute;
top: 0px;
left: 15%;
width: 70%;
min-height: 100%;
border: 1px solid black;
}
#header{
position: relative;
top: 0px;
left: 0px;
width: 100%;
height: 100px;
}
#contain{
position: relative;
top: 40px;
padding-top: 20px;
left: 5%;
width: 90%;
min-height: 600px;
border:1px solid green;
}
#footer{
width: 100%;
height: 5%;
bottom: 0;
border-top: 1px dotted black;
position: absolute;
}
如您所见,包含 div 的最小高度为 600 像素。 当页面填满时,它会正确扩展,但会扩展 越过页脚并超出“主”div。
显然我希望页脚保持在主页面的底部 次,但主要只是不根据包含 div 展开 即使它的最小高度是页面的 100%。
【问题讨论】:
-
你不能给#main的
min-height一个百分比。 -
top: 40px;正在将您的#contain 推到其他元素之外。
标签: html css sticky-footer