簡體   English   中英

頁腳不在頁面底部,而是在背景圖像的底部

[英]Footer not on the bottom of page, but on the bottom of background image

我想在我的網站底部放置一個頁腳,但是它在背景圖片的底部很粘。 我嘗試了很多技巧,但是無法將其放置在網站底部的所有內容下(我不想將其設置為固定的,但是一旦網絡向下滾動,我想使其在所有內容下可見完全)。 請查看附頁腳位置合適的圖片

請在下面找到我正在使用的代碼:

HTML

<!DOCTYPE html>
<html>
    <head>
        <link href="style.css" type="text/css" rel="stylesheet"/>
    </head>
    <body>
        <div class="background">
        </div>
        <div class="text">
            <h1>xxxxxx<h1>
            <h2>xxxxxxxxxxxxxx<h2>
        </div>
        <footer class="footer">Footer text</footer>
    </body>
</html>

CSS

    body, html {
    position: relative;
    height: 100%;
}

.background { 
    background-image: url("xxx.jpg");
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
}

.text {
    margin: auto;
    text-align: center;
    width: 70%;
}

.footer {
   position: absolute;
   left:0;
   bottom:0;
   height:50px;
   width:100%;
   background:#999;
}

我已經檢查了其他主題中的所有答案,但仍然找不到我的問題的解決方案。 謝謝您的幫助。

墊子,問候

更改css類頁腳,以刪除粘性頁腳:

.footer {
   position: relative;
   height:50px;
   width:100%;
   background:#999;
   display: block;
}

刪除position:absolute .footer類中的position:absolute

.footer {
   left:0;
   bottom:0;
   height:50px;
   width:100%;
   background:#999;
   display: block;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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