views:

49

answers:

3

Html

<div id="banner" style="display: block; background-image: url('images/swirl_home.gif'); background-repeat: no-repeat; background-color: #e7e7e7;">
    <div id="Hi">
                some text here...
        </div>  

    <div id="loader">
        <img src="images/ajax-loader.gif"  />
        </div>
    </div>

Css

#banner {
    background-color: #e7e7e7;
    min-height: 285px;
}

the above code renders perfectly in Mozilla and Chrome. Fails entirely in IE 6/7/8. The background image just doesnt show. I can see the text though.

What am I doing wrong...?

EDIT: its not a problem of the image path. i tried giving an absolute path as well. didnt work.

A: 

Try this, it will make the loader image appear as your div background whenever it is called.

 #loader {
        background-image:url (images/ajax-loader.gif);
/*Don't forget to set width and height to the size of your loader image here*/
        }

Also try to keep your styles altogether in the CSS, it seems you have an inline style as well as cSS styles with your banner ID, and if you want to use it more than once on a page, change it to a class and not an ID: Use .loader instead of #loader in the CSS and HTML <div class="loader">&nbsp;</div>. The &nbsp; is a non breakign space, just a non visual filler to force your DIV to be displayed.

Other than that, the path to the image might be broken, but I've never heard of IE messing up an image path differently to other browsers.

Kyle Sevenoaks
i dont understand. i dont want the loader image as the background image. and why did u write, imagesimages/ajax-loader.gif? is that a typo?
amit
Yes, it was. Your question is called "background image in IE" and your code shows that you didn't code a background image but an image element in the HTML. At least that's what I understood from it.
Kyle Sevenoaks
i have a parent div with a background-image. and then there is a child div with some text in it. there is another child div with the ajax-loader.gif in it. this is the structure. the parent div is loading up fine, but the background image does not show.
amit
In that case, I don't know why it wouldn't load properly. Do you have a live example? Check tha paths, maybe you're missing a ../ or /
Kyle Sevenoaks
yes i do. http://amit-verma.com/index_old.php
amit
Nice page! Thanks for the link, when do you want the image to appear? When you click "Hire me"? I put the image path into IE and it displays. Also your doctype is "http://www.facebook.com/2008/fbml". Possibly change that if this is not a Facebook page.
Kyle Sevenoaks
do you think the doctype is causing trouble. the image should appear below the top black bar and above the recent projects text.
amit
I think the doctype definitley wrong <html xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">lookup on "http://www.w3schools.com/tags/tag_DOCTYPE.asp" for your correct doctype.
Kyle Sevenoaks
In Chrome and firefox, the loading image flashes just for a split second when I hover over the links on the left. I honestly don't know why that would happen.
Kyle Sevenoaks
the doctype wasnt the problem. i didnt mention the width and height of the image.
amit
@Kyle: that is javascript. doesnt the image change when you hover on it?
amit
A: 

Solved it. the reason for the image not showing up was that I didnt mentioned the height/width constraints. What can I say, IE just brings the evil out of everyone.

amit
oups .. just posted the solution too ... glad you got it yourself.
Gaby
Aha, well that'd solve it. Glad you got it!
Kyle Sevenoaks
+2  A: 

You need to put a height to the #banner css rule, as you use min-height which is not supported by IE

put

height:auto!important;
height:285px;
min-height:285px;

and it should work ..

Gaby