The Blog

IE7 bug 1: nested list (abs. positioned) is overrun by preceding link’s background colour

I have encountered one ugly bug in IE7 rendering engine, which you could see in the last week at the main navigation of this site (at the top). It manifests when hovering items that has submenus, in which case nested list of items appears, like this:

Working layout

However, in IE7 you would’ve seen this:

Buggy layout

I had no idea what caused this, even asked in IE’s web dev forum without any answers received. Then, last night, while working on new version of this two-level navigation, I realized that it works, with bare styling. After an hour or so spent dissecting the CSS rules one by one, I found the culprit.
I have used the following rule to style the curently hovered main item:

CSS:
  1. ul.navig li:hover a {
  2. color: #000;
  3. background-color: #ff4500;
  4. }

The problem is the background-color rule. As soon as you remove it, sub-items re-appear. I have changed the style into this, which does not trigger the bug:

CSS:
  1. ul.navig li:hover {
  2. background-color: #ff4500;
  3. }
  4. ul.navig li:hover a {
  5. color: #000;
  6. }

Take a look at the example page which illustrates the problem. This is the nastiest IE7 bug I have encountered so far.

Apart form this, IE7 did not bring much problems. It is a very good release where most of the IE6 bugs are resolved. Some have remained though, like z-index problems. The lack of support for the :after pseudo-selector requires you to use zoom:1 in all places where you have used height:1% previously — in the IE7 only styles hidden by cond. comments (there are other solutions as well).
One another bug have remained too, again with this type of navigation, which I will demonstrate in another post.

Banca

Banca

Beautiful and functional currency converter, supports just about any currency in the world.

Go Couch to 5k

Go Couch to 5k

The most popular starter running program in beautiful feature-rich app (GPS tracking, charts, detailed history etc)

Quickie to do

Quickie to do

The fastest short-term task-list / check-list app on the App Store. Really.

Guerrilla Cardio

Guerrilla Cardio

The most challenging high-impulse interval training in the world.

Run Mate

Run Mate

A versatile running coach app, with unlimited number of running programs. Perfect for casual runners.

10 Comments

Feel free to chime in, looking forward to it. Leave a Comment

  1. matthijs says:

    Wow, that looks like a nasty bug. Thanks for the writeup. I’ll add this one to the list of bugs to remember.

  2. Matt Harris says:

    This is a wonderful post! Thanks for sharing.

    I’ve been putting off troubleshooting this issue on a couple of sites that I have developed. You just saved me four or five hours of frustration.

  3. Mark Hutton says:

    Superb, thanks… I’ve experienced this exact bug with nested lists used as navigation too

  4. This is really interesting, because I’ve been finding similar “disappearing content” bugs, always ultimately triggered by a background color or image.

    There’s a fuller (but still rough) write-up at http://www.cayenne.co.uk/ie7/disappearing-content.html. In all cases the presence of either “background-color” or “background-image” on a parent or ancestor is the culprit. Looks like this is another example of this more generic bug, which is reassuring, cos it means I’m not just going mad!.

    The basic, generic fix is to ensure the parent/ancestor with the background “hasLayout” (or any ancester of the missing content which is also a descendent of the element with the background — sorry, I haven’t found a clearer way to say that yet. See the link above for examples). So moving the background to the element fixes the problem because the “hasLayout” (from the float:left property). If the <a> is given layout this would also fix the problem. This might be useful if for any reason your design doesn’t allow you to apply the background color/image to the . In IE 7 you can trigger layout with min-height: 1% or min-width: 1%, neither of which should normally affect your layout at all.

    Ultimately we’re looking at a fun new instance of the basic IE peekaboo bug. What fun!

  5. Aleksandar says:

    Thanks for sharing the experience and your findings Sophie. It seems that all things in IE work fine if you trigger hasLayout. Maybe putting * {min-height:0} at the start of each CSS would be good practice. ;)

  6. Josh says:

    Just checked the example with the official IE7 release, and I believe the bug is now fixed…

  7. Aleksandar says:

    Josh, I have final IE7, downloaded one day after it was released and the bug is spotted in it. Are you sure it is fixed? Did you maybe download recently — maybe Microsoft posted a newer file although I think it’s highly unlikely that they do that.

  8. Fanny says:

    Eventually, the nested list language used for IE 7 does not work in IE 6.
    The website I put is the screen capture from my IE 6.
    No hover effects shown on the nested list.

  9. Aleksandar says:

    Fanny, that is expected, as IE6 is not supporting li:hover. It’s an illustration of the IE7 bug, which does support it.

  10. Matt Stow says:

    Hi Aleksander

    Thanks for finding and documenting this. I wasted hours trying to fix my “popup” navigation in IE 7 yesterday. I thought it was due to my javascript which repositions the menus on screen (should they appear off), and can’t believe it was something this stupid! Thanks IE!

    Cheers

    Matt

Comments are now closed for this article.