我试图让我的页脚粘在页面底部(在页面内容的末尾,即使内容比屏幕大)我尝试了很多东西,也许有些东西与代码冲突,因为它看起来很简单。
这是我正在尝试的基本代码:
<body>
<div id="main">
- a lot of divs and content, pictures, etc -
<div id="footer1">
- footer content -
</div>
</div>
</body>
在 CSS 上:
body
{
height:100%;
position:relative;
}
#main
{
height:100%;
position:absolute;
}
#footer1
{
position:absolute;
width:100%;
height:150px;
bottom:0px;
left:0px;
background-color:#5B5B5B;
}
请注意,我已经尝试删除 div“main”,也尝试使用:
<footer>
在 body 标签而不是 div“footer1”之后,没有任何效果,除非我将 body 高度手动设置为一个数字而不是 100%,比如 1200px,然后页脚转到 1200px 位置,不知道为什么它没有' 100%认不出来,我也试过:
<div style="clear:both"></div>
在页脚 div 之后
另外,我不想要一个固定的屏幕页脚“position:fixed”
最佳答案
谢谢您的回答,问题是我没有设置“最小高度:1000 像素”(我的内容的近似像素),现在可以正常工作了。
关于php - 无法使页脚粘在页面底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48067153/