簡體   English   中英

保留頁腳和頁面底部

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM