[英]Keeping footer and bottom of page
我有一个网页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 fixed
footer {
clear: both;
margin-top: -200px;
position: fixed;
bottom: 0;
width: 100%;
height: 2.5rem;
text-align: center;
}
您必须添加 position:relative; 在你的身体元素上
body
{
position:relative;
}
#photos
{
margin-bottom:100px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.