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

Comments

  1. 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.


  2. Phil Says:

    One day Brandon, one day we won’t have to worry about that wreck of a browser.

    Glad this helped though!


  3. Xander Says:

    Thank you Phil, you helped me with solving the issue.


  4. Tim Says:

    I was having the same problem with a mootools sliding image gallery. Your fix worked great.

    Thanls


  5. Matt Says:

    Thanks heaps :-)


  6. 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.


  7. Bas Says:

    Thanks for the solution! I had the same problem in two projects, problem solved within 10 seconds.


  8. R. Sigg Says:

    You. Are. A. Genius!

    (Down with IE6!)


  9. Mike Says:

    Thank you very much for sharing this monumental discovery.

    I have been struggling with this for … weeks.


  10. 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.


  11. 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.


  12. enkosynthesys Says:

    that was veeery helpful. spend two days alignin flash object inside a container. Thanks!


Leave a Comment