我有一个网页https://jiwidi.me/home/我有一个页脚,即使我用js代码注入html代码,我也希望它留在页面的底部。页脚在主页上工作https://jiwidi.me/home/但不喜欢https://jiwidi.me/home/blog/例如它不在底部的地方。在博客页面中,我实时插入html代码,这样页面的尺寸就会发生变化。
我当前的页脚css如下:
footer {
clear: both;
margin-top: -200px;
position: absolute;
bottom: 0;
width: 100%;
height: 2.5rem;
text-align: center;
}
页脚也应保持居中。
谢谢!
您必须添加position:relative;在你的身体元素
body
{
position:relative;
}
#photos
{
margin-bottom:100px;
}
您只需使用位置fixed
footer {
clear: both;
margin-top: -200px;
position: fixed;
bottom: 0;
width: 100%;
height: 2.5rem;
text-align: center;
}