views:

316

answers:

5

I have the following css:

body {
     background-image: url(images/background.jpg);
     background-repeat: repeat-x;
     background-color: #99ccff;
}

Unfortunately, any div created on this page, now automatically has this colour. None of the following works if applied to any divs on he page (it still takes on the above colour.

bacgkround: none;
background: transparent;
bacgkround-color: none;
background-color: transparent;

Anybody know how to get around this (in IE)? i.e. How do I make the div transparent or NOT have a background color?

EDIT: I've uploaded a screenshot here: http://www.namhost.com/bgtrans.jpg Basically, the background is a gradient image that changes from DARK blue, to the light blue that is the background. In firefox, the area that says bradd pitt, is transparent and you dont see the blue outline. However, in IE, you see what you see in that screenshot.

Here's a screenshot of what can be seen in Firefox: http://www.namhost.com/bgtransfirefox.jpg

+1  A: 

Your assumption of background color seems to be wrong.

Making a background transparent means you will get the background of the underlying element. I think in this case its your body element. Since you have set a background color for the body tag all the element with background color transparent will show the body's background color.

Edit:

After reading your comment to the above answer I would like whether the image path is shown and the image width and height cover the whole body element.

rahul
I've added the changes in my original post.
RD
I've also added screenshots! :-)
RD
A: 

If you could use a 3rd party tool, JQuery provides this functionality:

http://mihaistancu.wordpress.com/2008/08/02/cross-browser-transparent-background-with-jquery-no-css-hacks-no-png-files/

Russell
A: 

But I think this is what's supposed to happen.

If the div isn't assigned a background colour, the body background colour will be visible.

Especially if you say the div background is transparent.

pavium
Maybe i wasnt clear. To the new div, I added those "background: transparent" entries, and the div still shows the body's background, and NOT making it transparent.
RD
I'm afraid I don't get it yet ... aren't you describing a situation where the body's background is visible BECAUSE the the div's background is transparent?
pavium
No i am not. :-) See my comment above. I forgot to mention the page also has a background-image. I will see if I cant put an example online.
RD
+2  A: 

not sure whats going wrong here (if anything is going wrong at all), transparent and none mean that the div shouldnt have its own colour and therefore you will see through the div to the background of the parent container....if none of the parents have a colour then you will see the background of the body/page

Mauro
Ok. more info. the body has a background-image AND a color. And the div is over the IMAGE part of the background. So, in theory, if it was transparent, you should see the image. However, I see the COLOR. I added a border around it, which makes it clear that the div is in fact one solid color and NOT transparent.
RD
A: 

not sure what you expected. I get consistent behavior in firefox and IE for this code:

<html>
<style>
body
{
    background: green;
}
.a
{
    bacgkround-color: none;
}
</style>
<body>
<div class="a">hello</div>
<div>world</div>
</body>
</html>

if this is a more complex scenario, did you use debugBar to check the applied style, or at least FireBug on firefox to see what is actually applied?

Yonatan Karni