如何在底部保留(绝对)页脚
How to keep (absolute) footer at the bottom?
我想将页脚保持在页面底部,同时保持绝对位置,具有以下页面结构:
<div id="head"> </div> //want to keep its size auto and always on the top (position absolute)
<div id="body"> </div> //the children of #body have position absolute (keep size auto)
<div id="foot"> </div> //want to keep this at the bottom (just below body , if body size
changes then footer will also change (position absolute)
我该怎么做?
编辑
我想我不清楚我的问题,很抱歉,但我的实际问题是,在 #main(高度:自动)中,内容是绝对的,因此这些内容不包括在 main 的高度中(我只是猜测这个),这就是为什么 main 的高度是 0,因为页脚出现了。这是我的实际问题。
使用 bottom:0
:
#foot {
position:absolute; /* your requirement, you can also use fixed though */
bottom:0;
/* your other possible styles */
}
请记住,要使bottom
正常工作,您必须按照:)所述指定position
如果您使用 position:fixed
,当您滚动时,页脚仍将在页面底部可用,但它取决于您的要求。
如果我理解正确,你需要position:fixed
而不是绝对的。
#head {
position:fixed;
height:30px;
top:0;
left:0;
right:0;
}
#foot{
position:fixed;
height:40px;
bottom:0;
left:0;
right:0;
}
#body{
padding-top:30px; /* the same as the #head height*/
padding-bottom:40px; /* the same as the #foot height*/
}
http://jsfiddle.net/ZXMTR/演示
相关文章:
- 浮动页脚栏-使用Bootstrap隐藏
- 如何处理10页以上的静态页眉/页脚
- 打印预览没有应用程序页眉和页脚的html表格
- 当库在页脚中加载时,基于PHP条件调用Javascript
- 尝试求和时,在我的表的页脚中返回$NaN
- 在页脚处停止固定侧边栏-防止重叠
- 当地址栏出现时,安卓系统上的css固定页脚被隐藏
- 带有浮动子菜单的浮动页脚菜单
- 如何仅在向上滚动时将页脚粘贴到窗口底部会导致页脚不显示
- 当我在页脚中打开下拉列表时,关闭页眉中的下拉列表(下拉列表具有相同的类)
- 返回页首按钮和页脚(定位)
- 在页面的页脚处添加了一个额外的输入字段
- 根据页眉和页脚高度更改高度的动态内容
- 如何动态更改页眉和页脚
- 所有网页中的通用页眉和页脚,不使用PHP,JSP,ASP
- 在我的内容使用 Javascript 淡入后,如何加载我的页脚
- 粘性侧边栏停止在页脚上方 30px
- 如何在底部保留(绝对)页脚
- 页脚的动态绝对位置,缺少像素 - 无限滚动
- 在一个绝对位置弹出,用数据角色=“0”滚动;页脚”;