CSS First-Aid for IE Peekaboo Bug

That annoying IE peekaboo bug just doesn’t know when to stop. Apparently, even IE7 exhibits this bug, and it appears to be worse than its predecessor. If you happen to be pressed for time (or are lazy to search the Internets for a solution), applying a couple of stylesheet rules to the affected element should solve most peekaboo problems for both IE6 and IE7:

position: relative; /* peekaboo bug fix for IE6 */
min-width: 0; /* peekaboo bug fix for IE7 */

Take note that I said most. These two lines work for me lots of times, but then again I don’t get to encounter every known variant of the peekaboo bug. What I like about this is that it takes a few seconds to apply (hence the “First-Aid” designation in the title), and it’s perfectly valid code: no hacks performed, and it doesn’t even need conditional comments. There will be instances where one or both rules may conflict with your own rules (or they just won’t work), in which case other fixes may be more appropriate.

Note: min-width: 0; can be replaced with any other (equally non-destructive) rule that triggers hasLayout, such as zoom: 100%;.

Related posts
  1. An Even Better IE Button Width Fix
  2. Simple Relative Font Size Equation
  3. Standards-Friendly IE Button Width Fix

27 Responses to “CSS First-Aid for IE Peekaboo Bug”


  1. 1 Brendan Knowles

    Thanks so much - this has helped me heaps

  2. 2 Rosco

    Thanks for that, a nice fix quickly found!

    how much do I hate IE?

  3. 3 SEO

    You know what, i’ve been cracking my head over what’s causing this for some people for a while now and had no idea it was called the “Peekaboo Bug” or what was causing it or how to resolve it.

    … and that tiny bit of code provides a fix.

    Blond females… Sheesh :D

    Thankyou for this, Carly

  4. 4 aj batac

    will keep this on my bookmark just in case. :)

    thanks.

    –aj

  5. 5 bent

    And once again, so as not to offend the sensitive, I silently reiterate the long string of expletives towards the creator of IE and loudly proclaim my thanks for this little gem of a fix.

    Thanks

  6. 6 Des

    Thank you so much — I was getting this problem in IE7 and could not figure out how to solve it.

  7. 7 Mozal

    I looked for the peekabo bug and ways to solve it. Many times i found this solution with min-height:0 and position:relative. But the last one wasn’t an option for me so i looked further …

    I found another way myself and probably the cause of the peekabo. In IE6 a div has a default hight caused by a default line-height or somethings so people who create a clearing-div after floating items, create an extra height they don’t want.

    The other sollution is to fix this height in your clearing div … like this:

    div.clear{clear:both;height:0;line-height:0;font-size:0;}

  8. 8 neuston

    Here is more information for reference:
    http://www.positioniseverything.net/explorer/peekaboo.html

    IE, come on, disappear~~~

  9. 9 Toukie

    I don’t know if my problem is the peek-a-boo bug in action but I can’t get the main content box to expand in IE. My temp workaround for visitors is to ask them to increase the page font size either through their browser on with the tool on my site.

    I have spent hours searching for a way to fix this. My only problem is I am not sure where I would apply your code? Can anyone help?!!!!!!
    http://www.canadianblues.ca

  10. 10 Toukie

    I could just kiss your feet!! I tried your code in the section that I thought was causing the problem and that did it! xoxoxoxoxoxoxoxo

  11. 11 Toukie

    well I spoke too soon. The fixes worked in IE7 but not in IE6. I don’t know anymore if my problem is the peek-a-boo bug. Your fixes solved my text not appearing problem but it did not fix the content box problem. It does not expand when the text overflows. Back to square one!

  12. 12 Brownspank

    Toukie: It seems you have a different bug. The peekaboo bug involves elements not showing up, while your bug is more of a float issue. I’m glad the first-aid helped you in other problem areas, though. :)

  13. 13 vitaly

    Thanks. It helped me too.

  14. 14 Dui

    Dang. This is an awesome find! 2 lines will usually patch it? Great info my friend. Glad I stumbled on ya here.

    :O)

  15. 15 Matt

    Just wanted to say thank you! IE7 hurts to develop for and this peekaboo bug has to be one of the more annoying!

    cheers.

  16. 16 freaky

    thank you so much! could’t believe this tiny bit of css saved me so much trouble!!

  17. 17 Pete

    You rule. I did go with an absolute position because I am lazy that way. Nevertheless, my css tweak worked:

    .hizMenu
    {
    z-index: 900;
    position: absolute; /* peekaboo bug fix for IE6 */
    min-width: 0; /* peekaboo bug fix for IE7 */
    left:0px;
    top:0px;
    }

    And p.s., you rule.

  18. 18 KARPOLAN

    Thanks!

    min-width: 0;

    really works.

  19. 19 mmorpg

    thank you for this solution

  20. 20 nightox

    Thank a bunch !

  21. 21 William

    Thanks mate. I’ve been searching for a solution for this PeekaBoo bug for a long time.

    Nice one for sharing.

  22. 22 Peter

    It works… thank you so much!

  23. 23 A Williams

    Thanks for the fix! This is the most clear guide I have found relating to the peekaboo bug in IE7.

    Cheers!

  24. 24 Order

    Thanks for the fix!

  25. 25 Brighton Photos

    Spot on; I love quick and simple fixes! Fortunately this was the first page that I came by. Greatly appreciated.

  26. 26 Diamond Blade Dealer

    Thanks for the fix! saved me a lot of time:)

  27. 27 MB

    Nice one, cheers!

  1. 1 Software utilities » IE7 Peekaboo bug, disappearing text

Leave a Reply