简体   繁体   English

背景图片不会扩展到页脚

[英]Background image won't stretch to footer

So I am building my website. 所以我正在建立我的网站。 I added my banner , my footer but my background is getting messed up. 我添加了横幅和页脚,但背景变得一团糟。 It's not stretching out , there is some empty whitespace. 它没有伸展,有一些空白。

This is what happens: 这是发生了什么:

If I use background-size: 100% , my background disappears. 如果我使用background-size:100%,我的背景就会消失。 Same thing when I use background-size: cover;. 当我使用background-size时,同样的事情:cover;。

HTML: HTML:

<div class="content">
</div>
<div class="footer">
</div>

CSS: CSS:

.content {
min-height: 690px;   
background: url("background.png")
background-size: 100%;
}

.footer {
min-height: 200px;
background: url("footer.png");
background-repeat: repeat-x;
}

Instead of background-size: 100%, try background-size: cover. 代替background-size:100%,尝试使用background-size:cover。 Cover will stretch the image to always fully fill its container, cropping any excess. 封面将拉伸图像以始终完全填充其容器,裁切多余的部分。

 .content { min-height: 690px; background: url("background.png"); background-size: 100% 100%; } .footer { min-height: 200px; background: url("footer.png"); background-repeat: repeat-x; } 
 <div class="content"> </div> <div class="footer"> </div> 

You have missed ; 你错过了; after background: url("background.png") . background: url("background.png")之后background: url("background.png")

Try this code. 试试这个代码。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM