将背景图像居中
请看一下上面的屏幕截图,我想将黑色背景的图像居中,但是我在底部有一些空白。请任何人帮我解决这个问题。
CSS
.bgimg {
background: url('../images/GBS-Chronicle-Background-1.png') black no-repeat center;
}
div#cont {
height: 672px;
}
HTML
<body class="bgimg">
<div id="doc2">
<div id="hd"></div>
<div id="bd">
<div id="cont">
<div class="middle">
<p> hi hello </p>
</div>
</div>
</div>
<div id="fd"></div>
</div>
Please have a look at the above screen shot, I would want to center an image with black background, but i'm getting some white space at the bottom. Please could any one help me to fix this.
CSS
.bgimg {
background: url('../images/GBS-Chronicle-Background-1.png') black no-repeat center;
}
div#cont {
height: 672px;
}
HTML
<body class="bgimg">
<div id="doc2">
<div id="hd"></div>
<div id="bd">
<div id="cont">
<div class="middle">
<p> hi hello </p>
</div>
</div>
</div>
<div id="fd"></div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试添加这个:
Try adding this:
尝试在
.bgimg
类上设置height:100%;
。编辑:您可能还需要将
padding:0;margin:0;
设置为您的.bgimg
类,以确保安全。Try setting
height:100%;
on your.bgimg
class.Edit: You may also want to set
padding:0;margin:0;
to your.bgimg
class as well just to make sure.我猜 GBS-Chronicle-Background-1.png 不够高。您可以将背景颜色添加为黑色或与 Y 一起重复图像。
I guess GBS-Chronicle-Background-1.png is not high enough. you can either add background color to black or repeat the image along with Y.
尝试更改背景规则的顺序,使颜色排在第一位。
Try changing the order of your background rule so the color comes first.
也试试这个(正如上面建议的那样):
body {color:#000000;}
另外:我建议也注释掉内容 div 的高度。和/或将内容 div 的 bkg-color 设置为与正文相同的颜色。希望有帮助! :)
try this too (as has been suggested above):
body {color:#000000;}
Also: I would suggest commenting out the Height of your content div as well. And/or setting the bkg-color of the content div to the same color as the body. Hope that helps! :)