views:

83

answers:

4

I have a div that contains a PNG background-image. After the div is displayed on my web page in IE7, there is a whitespace between the div and footer. All other browsers (incl. IE8) display the PNG correctly. Any ideas on a resolution would be appreciated?

A: 

It's very likely you have white space surrounding your img tag which renders a single white character in IE6 and IE7.
I assume your code looks like:

<div>
    <img/>
</div>

Try making it:

<div><img/></div>

So:
- no whitespace
- no new line characters

Michal M
+1  A: 

Just a thought here, but maybe it's the browser's stylesheet that is adding that whitespace?

Try using a CSS Reset.

Jorge Israel Peña
Added blueprint css reset and it resolved the issue. I am using the blueprint css framework but did not include the reset file. Thanks!
Rich Blumer
You're welcome :)
Jorge Israel Peña
A: 

Forcing the browser to treat the image as a block element should nullify any inherited margins that it is given. Try this:

<style type="text/css">
.blockify { display: block; }
</style>

<img src="/path/to/my/image.png" width="100" height="100" class="blockify" />

Keep in mind that your image now behaves like a DIV tag. So apply your formatting / positioning accordingly. For example, if you want to center your graphic, you should do so like any other DIV element:

<style type="text/css">
.blockify { display: block; margin: 0px auto; } 
/* auto margins help center block elements */
</style>
Joe D
A: 

Thanks Michal M

The below mentioned trick is working for me. div-img-div

Thanks again

Rishabh