簡體   English   中英

平鋪背景圖片停在內容底部,而不是頁面底部

[英]tiling background image stops at bottom of content, not page

我試圖使背景圖像平鋪並覆蓋整個頁面,即使沒有足夠的內容來填充頁面。 現在,背景圖像停止在內容的底部。 我使用了粘性頁腳修復程序來將頁腳保持在頁面底部,因此剩下的是內容底部和頁腳之間的一堆空白。

我不想用marginpadding空間,因為這不會擴展到更大的顯示器。

我已附上問題的圖片:

在此處輸入圖片說明

這是CSS:

.static_pages {
    background-image: url('../img/cream_dust.png');
    background-repeat: repeat;
    position: relative;
    overflow: hidden;
    width:  100%;
    height: 100%;
    margin: 0;

}

.static_content {
    width: 80%;
    margin: 3em auto 0 auto;
}
.static_content h1 {
    color: #193441;
}
.static_content p {
    color: #193441;
    text-align: left;
    margin-top: 2em;
}
.static_content ul {
    color: #193441;
}

和HTML

<?php include_once('header.php'); ?>
    <section class="static_pages">
        <div class="static_content">
            <h1>Header</h1>

                <p>A little Text</p> 

        </div><!-- END class="static_content" -->
    </section><!-- END class="static_pages" -->
<?php include_once('footer.php'); ?>

有任何想法嗎? 我已經為此戰斗了一段時間。 謝謝!

編輯:!doctype和所有其他標頭信息在包含的header.php文件中。 這只是該網站上的幾個頁面之一。 我有一個主索引頁面,它是一個長的着陸頁面,而這是一個靜態頁面,用於聯系,聯系等內容。

將背景放在HTML標記上:

html {
    background: transparent url('../img/cream_dust.png') scroll repeat 0 0;
}

您需要使用:

  1. 正確的doctype

     <!doctype html> 
  2. body背景

     body { background-image: url('../img/cream_dust.png'); background-repeat: repeat; } 
  3. 全高身材!

     body {height: 100%;} 

使用不同的背景圖片:

<body class="pageOne">
<body class="pageTwo">
<body class="pageThree">

的CSS

.pageOne {background-image: url('../img/cream_dust.png');}
.pageTwo {background-image: url('../img/cream_sandwich.png');}
.pageThree {background-image: url('../img/cream_sand.png');}

暫無
暫無

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

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