IE6 Doesn’t Hide When Overflow Is Hidden
Posted on Tuesday, February 12th, 2008
A little CSS bug that affected me twice recently. I had to create a news ticker (so 1990s, but not my design) and an image slider, both which did the same thing; moving information from one side of the screen to the other. The important part was, at some point the news or the images would disappear, seemngly sliding underneath the next part of the page. Of course, this worked in all browsers but every developer’s favourite, Internet Explorer 6. Let me explain why this was happened and what I did to fix it.
The Problem: Position Relative
In order to create the effect of moving both the news ticker and the images, I set up something like the following:
<div id="slide_frame">
<ul>
<li>Item one</li>
<li>Item two</li>
<li>Item three</li>
<li>Item four</li>
<li>Item five</li>
</ul>
</div>
With the following CSS:
#slide_frame { width:300px; }
#slide_frame ul {
list-style-type:none; position:relative; width:600px;
}
#slide_frame li { float:left; padding:0 5px; }
The sliding was done with JavaScript, jQuery, which I am falling in love with, as it happens, and the result was fine in all browsers but IE6 where both the news ticker and the image slider remained visible at all times.
The issue, it seems, comes down to the <ul> being positioned relatively, which had to be done, so that the JavaScript could move it about. Removing the position hid the out of shot part of the list but meant it wouldn’t move anywhere.
The Solution: Position Relative
Thankfully, this turned out to be an easy fix! In order to make IE6 behave all you need to do is apply position:relative to the containing <div> as well. Don’t go around playing with z-indexes like I did for half an hour anyway!
I have provided an example of the problem, with the fix to show what should be happening. Interesting point for those of you with many, many versions of Internet Explorer at your disposal, IE5 and 5.5 are not affected by this issue.
So, don’t get caught out by hidden overflow and relative positions again, just position your container relatively too!
If you enjoyed this post, why not subscribe to Unintentionally Blank
1July 20th, 2008 at 7:26 am
Brandon Says:Thanks a ton! I constructed an image slider using Mootools and I had the same problem. Nice work. I just wish the world would come together as a whole and say that no one will use IE6 every again. It would make our jobs easier.
2July 22nd, 2008 at 10:26 pm
Phil Says:One day Brandon, one day we won’t have to worry about that wreck of a browser.
Glad this helped though!
3August 22nd, 2008 at 7:07 pm
Xander Says:Thank you Phil, you helped me with solving the issue.
4September 9th, 2008 at 2:54 am
Tim Says:I was having the same problem with a mootools sliding image gallery. Your fix worked great.
Thanls
5September 15th, 2008 at 1:29 am
Matt Says:Thanks heaps :-)
6September 22nd, 2008 at 10:18 pm
Daniel R. Ziegler Says:Thank you thank you thank you so much! I have been struggling with this problem for the past week reading as much as I could about every possible quirk in IE but none solved my problem like yours. I would call you a god, but that would be blasphemy.
7October 23rd, 2008 at 9:03 pm
Bas Says:Thanks for the solution! I had the same problem in two projects, problem solved within 10 seconds.
8November 11th, 2008 at 10:08 pm
R. Sigg Says:You. Are. A. Genius!
(Down with IE6!)
9November 19th, 2008 at 11:16 pm
Mike Says:Thank you very much for sharing this monumental discovery.
I have been struggling with this for … weeks.
10November 25th, 2008 at 7:41 pm
dnnsldr Says:Thanks for the solution. I am using the Prototype Carousel and all that was needed was the position:relative added to the .container class and everything works great in IE6 now. Thanks again for the solution.
11December 10th, 2008 at 1:06 pm
Olly Hodgson Says:Phil, you’re a scholar and a gentleman. I thought I’d seen everything when it came to IE6, but then today I ran headlong into this lovely bug.
12December 18th, 2008 at 8:57 pm
enkosynthesys Says:that was veeery helpful. spend two days alignin flash object inside a container. Thanks!