div内的背景图像未显示 [英] Background-image inside div not showing up
问题描述
所以我在这个网站上工作,我展示了我想要的东西.在处理较低的页面横幅后,突然一切都消失了,我只剩下正文中的背景图像.
So I was working on this site and I had the displaying how I was wanting. After working on a lower page banner all of a sudden everything disappeared and all I was left with was the background Image in the Body.
你能弄清楚为什么 topImage id 不显示吗?看到它工作一秒钟而另一秒钟不工作,真是令人沮丧:
Can you figure out why the topImage id does not display? It is frustrating as hell to see it work one second and then not the other:
<style>
body
{
background-image:url("images/Background.gif");
background-repeat:repeat-y;
background-attachment:fixed;
background-position:center top;
}
#topImage
{
position:absolute;
background-image:url("images/Top-Banner.gif");
background-repeat:repeat-x;
width:100%;
top:0px;
left:0px;
}
</style>
<body>
<div id="topImage"></div>
</body>
对不起,如果这是一个非常基本的问题,我对此有点陌生.
Sorry if this a really basic question, I am kind of new at this.
推荐答案
#topImage
没有设置高度,也没有设置高度的元素.
#topImage
doesn't have a height set, and no elements inside it which would give it a height.
#topImage
{
position:absolute;
background-image:url("images/Top-Banner.gif");
background-repeat:repeat-x;
width:100%;
height: 100px; /* Change to the height you need */
top:0px;
left:0px;
}
或者只是在 div
中粘贴一个 img
标签,而不是使用 background-image
,这样也可以.
Or just stick an img
tag inside the div
instead of using background-image
, that would work as well.
这篇关于div内的背景图像未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!