背景图像内DIV没有显示出来 [英] Background-image inside div not showing up

查看:205
本文介绍了背景图像内DIV没有显示出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在做这个网站,我有我展示如何想。
在一个较低的网页横幅工作全部消失了,突然一切都和所有我留下了之后在身的背景图像。

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 标签,这将正常工作。

Or just stick an img tag inside the div instead of using background-image, that would work as well.

这篇关于背景图像内DIV没有显示出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆