保留页脚和页面底部

时间:2021-04-16 21:38:49

标签: javascript html css web

我有一个网页 https://jiwidi.me/home/,我有一个页脚,即使我用 js 代码注入 html 代码,我也想留在页面底部。页脚在主页 https://jiwidi.me/home/ 上工作,但不会在 https://jiwidi.me/home/blog/ 上工作,例如它不在底部的地方。在博客页面中,我正在插入 html 代码,以便更改页面的尺寸。

我当前的页脚 css 如下所示:

String temp = "I|123|abc|2021-01-03 12:15:33"
tmp.replaceAll("<regexDateFormatt>", initialFoundDate.substring(0,19))

页脚也应该居中。

谢谢!

2 个答案:

答案 0 :(得分:0)

您可以只使用位置 fixed

footer {
    clear: both;
    margin-top: -200px;
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 2.5rem;
    text-align: center;
}

答案 1 :(得分:0)

您必须添加位置:相对;在你的身体元素上

body 
{
 position:relative; 
}

#photos
{
 margin-bottom:100px; 
}