【发布时间】:2012-09-17 21:16:12
【问题描述】:
我已经用谷歌搜索并阅读了关于制作“粘性页脚”的所有内容,但由于某种原因,我无法让它正常工作。这是我的 html/body div、主要内容 div 和我的页脚 div 的 CSS 代码:
body, html {
margin-top: 5px;
margin-bottom: 5px;
padding: 0px;
height: 100%;
font-family: Cooper Black, Copperplate Gothic Bold, Britannic Bold, Garamond, Arial;
font-size: 1em;
color: #666666;
background-color: #EDF5FC;}
#main {
position: relative;
top: 380px;
width: 90%;
height:100%;
min-height: 100%;
margin: 0px 5% -20px 5%;
z-index: 10;
padding-top: 0px;
padding-bottom: 20px;
overflow:scroll;}
#footer {
clear:both;
position:fixed;
margin-left:auto;
margin-right:auto;
margin-bottom:0px;
margin-top: -20px; /* negative value of footer height */
width:98%;
height:20px;
padding-top:3px;
background: #0E28B1;
text-align: center;
color: #ffffff;
font-size: .7em;
font-weight:bold;
z-index:1;}
我的页脚 div 在我的主 div 之外(网站的主要内容在主 div 内,然后我将其关闭并拥有页脚 div。)我可以通过使用固定位置和边距使其粘在底部-bottom: 0,但是我的内容没有滚动条。
这根本不起作用。我做错了什么?
【问题讨论】:
标签: html css sticky-footer