Skip to end of metadata
Go to start of metadata

A bug found in Internet Explorer versions 6 and 7 causes elements to disappear, and sometimes reappear. This bug is sometimes referred to as the "peekaboo bug" or the "relative/absolute position bug".

At the root of this issue is the IE proprietary concept "Layout", which "determines how elements draw and bound their content, interact with and relate to other elements, and react on and transmit application/user events." The elements that don't have layout are the ones that disappear when this bug is encountered.

Some elements, such as <table>, <tr>, <th>, <td>,<img> and<hr> have layout by default. Others, such as <div>, need to have certain CSS properties to gain layout.

To give layout to an element and avoid the risk of having it disappear in IE7 you can add one of these CSS rules, among others:

  • position: absolute
  • width: any value other than 'auto'
  • height: any value other than 'auto'
  • zoom: 1

A more complete explanation, as well as a full list of rules that give an element layout can be found on this page.

Fixing it in practice

I recently encountered an instance of the bug in which the element would disappear when the user would resize the window. This where the steps I took to fix it:

  1. Open Internet Explorer on the page in which the bug was found
  2. Open Development Tools by going to Tools > Developer Tools
  3. Select IE7 as the Browser Mode and IE7 Standards as the Document Mode
  4. Choose the HTML tab in the Developer Tools and navigate the DOM to the element that is disappearing
  5. Copy the div ID
  6. Go to the Script tab and, in the console, run id.currentStyle.hasLayout,  replacing the word "id" with the actual ID of the element If the result is "true", this element has layout and should not be a problem. If the result is "false", note it down.
  7. Keep going up the DOM tree and finding elements that don't have layout, and writing it down.
  8. Change the CSS of the elements that didn't have layout, adding a property such as "zoom: 1".

Now that all the parent  of the disappearing element have layout they should not disappear anymore.

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.