iandevlin.com

Icon

A mixture of musings on web design & development, history, and life

Fading issue with repeating background transparent image in Internet Explorer

ie transparency

Today I came across an interesting issue with transparent images being used as a repeating background in Internet Explorer 7 and 8 and thought that I’d share it with you in case you come across it yourself and become as baffled as I was.

The problem

I was using standard CSS to apply a transparent 1×1 PNG image as a repeating background for a div:
background:transparent url('images/transparent-bg.png') repeat left;
This worked fine in Firefox 3.6.2, which is what I was developing in (I usually check it in other browsers along the way at various stages), but when I checked it in Internet Explorer 8, the background was fine to the left, and then had faded to nothing by the time it got to the right and bottom of the div!

Here is what Internet Explorer 7 and 8 displayed it as:
ie transparent bug 1

And here’s what it’s supposed to look like:
ie transparent bug 2

I was a bit perplexed as to what was causing it and so turned to Google to see if anyone else had come across this issue, and there were some mentions of it, although not as many as I would have expected.

The solution

The problem turned out to be the size of the image being used. It was 1×1, and apparently this can cause Internet Explorer to get confused. Simply changing it to a 1×2 sized image, and Internet Explorer displayed it correctly.

Simple really as it turns out.

15 Responses

  1. [...] This post was mentioned on Twitter by html5laboratory and html5laboratory, Ian Devlin. Ian Devlin said: [new blog post] Fading issue with repeating background transparent image in #InternetExplorer http://bit.ly/9kPfgx #webdevelopment [...]

  2. Derek Johnson says:

    This had me completely stumped on a recent project.

    Thanks for coming to my rescue!

  3. ian says:

    Ha no worries Derek, as I mentioned, it had me stumped for a while too!

  4. Eamonn says:

    Amazing. Who would have thought it could have been something so simple (yet ridiculous).

    I probably spent the better park of a week on and off trying to get past this issue recently. Ended up just not using transparency in IE. Your exactly right too, lots of info on the web documenting this, nothing solving it.

    That was of course until you made this post! Nice job mate, cheers.

  5. ian says:

    Hi Eamonn, thanks for your comment. Yeah it took me a fair while to find the solution buried in some forums somewhere, hence I thought I’d make the post.

    Glad it helped you out.

  6. Keith Greer says:

    Thanks Ian, this has been bugging me for a while and I usually just revert to a 4x4px GIF (two solid, two transparent), thanks for the fix!

  7. [...] IE yes. I've had a fading issue with a repeating background in IE and this was the cause. The effects aren't exactly the same, but try it as a 1×2 image. [...]

  8. Östlund says:

    Thanks, I have this problem and couldn’t figure out what to do. We use a 1×1 pixel image in a project and get that strange fading. I guess a stupid fix like this is the curse of IE.

  9. ian says:

    Glad it helped. Drove me mad for a while too!

  10. Yan says:

    WOW! Unbelievable! Thanks a lot, I’ve been having this problem with a few of my sites and I just gave up on transparent png for IE!

    Curse you IE!!!

  11. ian says:

    You’re most welcome Yan.

  12. John Burton says:

    Thanks Ian, this had me completely perplexed. On the plus side, the fade can look really good. Just a pity that it isn’t then cross-broswer compatible…

  13. ian says:

    Glad it helped John!

  14. Jason says:

    Saved my but, thanks for this!

  15. dave says:

    Thank you for this tip – it only had me stymied for a few minutes before I hit the googles looking for a solution, but without your help, I’m sure I would have spent a day or two obsessing over it.

    WTH, Microsoft?

Leave a Reply