IE6 Hides CSS Images
Otherwise titled, "Multiple background images + the bane that is IE6". This explanation is in reference to my July 2007 CSS Off code.
In coding the design for the Early Bird h1 overlay, I implemented two overlapping background images: the pretty bird, and a horizontal grey bar.
-
/* Code for the horizontal grey bar */
-
#login{
-
background: #F7F7F7 url(../images/bg-header.gif) repeat-x 0 bottom;
-
color: inherit;
-
margin: 0;
-
padding: 10px;
-
text-align: right;
-
}
-
#login span{
-
display: block;
-
margin: 0 auto;
-
width: 900px;
-
}
-
-
-
/* Code for pretty, pretty birdie */
-
#header h1{
-
background: url(../images/logo.gif) no-repeat left top;
-
height: 189px;
-
margin: -26px 0 0 0;
-
padding: 0;
-
}
Whether I ought to have made it a CSS background-image or an HTML img is irrelevant at this point, as I found an annoying IE6 bug regarding multiple seemingly unrelated CSS background-images.
The bird background-image was hidden by the horizontal top bar. To resolve this, I used IE6 filters to hide the HTML img and display CSS background-image for modern browsers, but to display the HTML img in the case of IE6.
-
#header h1 img{
-
display: none;
-
}
-
* html #header h1{
-
background: none;
-
position: relative;
-
margin: 0px 0 0 0;
-
}
-
* html #header h1 img{
-
display: block;
-
position: absolute;
-
margin: -26px 0 0 0;
-
}
Why does IE6 present the background-image overlap issue? The Early Bird h1 required position:relative. Why? Because IE6 hates me with the fire of a thousand suns. If you discover a better reason, kindly let me know, as I find this animosity between IE6 and myself most unsettling.
Really, semantically, we should not be using a background-image if there was meaning associated with the image. I was torn in this case, as it really is subjective whether the item necessitates semantic meaning or not. The method I implemented in my example really displays how both methods can work: HTML img with the IE6 code, and background-image with modern browsers.
In conclusion: if your background-images are improperly overlapping in IE6, try adding a position declaration on the hidden element.




You know, I searched EVERYWHERE for this little bit of info. I cannot believe this is that uncommon.
Thank you!!
Perhaps you need to add keywords
multiple background images IE Internet explorer IE6 IE7 hides hidden CSS background
Wow! You really covered this topic well. If I wanted to know more, do you have any other resources that you would suggest?