我知道这个问题是一个老问题,但是经过研究和尝试了 2 天,我仍然没有运气,我希望这里有人能给我一些建议!
问题:
我有一个页面需要应用粘性页脚,通常很简单,但这就是我遇到问题的地方。
我可以让页脚 div(#footer) 毫无问题地粘在底部(它是 100% 的宽度,带有重复的背景图像)然后在这个 DIV 中,我将另一个(#cut)与 bg-image 浮动到右侧(我的例子中的剪刀)。这也很好用。
问题是我需要另一个 100% 宽度的 div(#footer-link-wrap) 在主要的下方,以便我可以在中心浮动一些导航链接(#links)。在#footer-link-wrap 中,我需要另一个图像一直向右浮动,尝试使用定位的背景执行此操作,但我无法让它工作。
我完全碰壁了,我将非常感谢任何反馈,我刚刚在长时间的休息后重新开始设计,这可能是我犯了一个愚蠢的错误。
CSS如下:
* {
margin:0;padding:0;
}
html, body {
height: 100%;
background-color:#000;
}
#wrap {
min-height: 100%;
}
#main {
overflow:auto;
padding-bottom: 60px;
}
#footer {
position: relative;
margin-top:-20px;
height: 20px;
clear:both;
width:100%;
background:url(foot-hair.png) repeat-x;
background-position:0 8px;
}
#cut{
float:right;
width:40px;
height:20px;
background: url(haircut.png);
}
#footer-link-wrap{
margin-top:-40px;
height:40px;
width:100%;
background:url(hair-fall.png) no-repeat;
background-position:bottom right;
}
#links{
position:relative;
margin-left:auto;
margin-right:auto;
width:800px;
background-color:#fff;
}
/*for opera
body:before {
content:"";
height:100%;
float:left;
width:0;
margin-top:-32767px;
}*/`
这是示例浮动帮助的链接