tags:

views:

105

answers:

4

I am rendering a small menu in the upper right-hand corner of a web site. There will always be a "Banner" graphic across the top of the page (1024x80 pixels) and the menu must render on top of it. In IE 7, IE 8, FireFox and Safari, the menu looks fine. In IE 6, however, the menu does appear sometimes and fails to appear at other times with no discernable pattern. In the CSS shown below, I placed the "z-index" in the class definitions after reading that this was a fix for some CSS problems of this type in IE 6. However, there is still no joy in Renderville. ANY help will be appreciated!

Here is the CSS defined for the page, the header and the menu:

Div.XPage { background-color: White; position:relative; width:1024px; border-left:1px solid #a4a4b1; border-right:1px solid #a4a4b1; margin:auto; text-align:left; z-index:10; }
Div.XHeader { background-color: White; clear:both; padding:0px; margin:0px; z-index:2; }
Div.XTopMenu { position:absolute; left:810px; top: 0px; width:214px; height:16px; background-color:#333333; z-index:3; }
Div.XTopMenuItem { width:70px; height:14px; margin-bottom:3px; text-align:center; float:left; }
Div.XTopMenuItem a { color: White; font-size:smaller; }

Here is the HTML that uses these CSS classes:

<div class="XPage">
    <div class="XHeader">
        <a href='/Home.aspx'><img src="/images/Header.png" alt="Banner Graphic" border="0" width="1024" height="80" /></a>
    </div>
    <div class="XTopMenu">
        <div class='XTopMenuItem'><a href='/Home.aspx'>Home</a></div>
        <div class='XTopMenuItem'><a href='/Calendar.aspx'>Calendar</a></div>
        <div class='XTopMenuItem'><a href='/Logout.aspx'>Log Out</a></div>
    </div>
    ...
</div>
A: 

Why z-index 10 for the Page? It's supposed to be way in the background, right? Could you try setting its index to 0 or 1?

Carl Smotricz
According to the information that I read about how to "fix" this, if you place a *higher* z-order on the parent control, you'd get its children to respect their z-order settings. That is, the parent doesn't compete with its children so having a higher parent value than child value isn't a problem. Of course, I'm still figuring this stuff out so I could be a bit off!
Mark Brittingham
OK, I understand. Good luck!
Carl Smotricz
+1  A: 

IE6 has issues with z-indexing. In IE6 z-index is only respected for siblings.

Things I'd try:

  • Reverse the order of menu and header in the html
  • Give the header a negative z-index
  • Give the menu a more significant lead on z-index than the header, say z-index:999.

Failing those you could try giving IE6 a different header image that didn't cover up where you want the menu to go. In many cases I've strived for IE6 to have degraded support, it's an ancient browser and has way too many problems. So if it's an option I'd consider letting it have a slightly different appearance. Of course that may not be up to you.

Bryan McLemore
+1 Thanks Bryan. I actually do have a choice in the matter and, technically, we don't support IE6. I just have a customer that I like a lot and I am trying to help her out. I'll try your suggestions and hopefully one of them will work.
Mark Brittingham
No, it's not that it only works for siblings. The z-index problem is that a new z-index context is established by any element that has a position.
erikkallen
There is a sibling related bug though. I just choose a poor way of stating it. A child's z-index can be super super high, but if it's parent's siblings are higher than the parents than the child will always show up under the parent's sibling.
Bryan McLemore
+1  A: 

z-index only works on positioned elements (position:absolute, position:relative, or position:fixed).

You do not have these on Div.XHeader thus that z-index is being ignored completely.

Read more about z-index on w3schools

corymathews
+1 - Thanks. I haven't really worried about the z-order of the header since it was a change to the z-order of the Page div that was supposed to work that magic (a higher z-order was supposed to make IE pay attention to the z-order of the menu). But thanks for the link!
Mark Brittingham
+1  A: 

No directly useful info, I'm afraid, just another suggestion in case you're sufficiently desparate:

Google has managed to solve this problem, and many more, in GWT. Hold off on the downvotes, please - I'm not sugesting rewriting the app in GWT. I am, however, recommending to look at their code. In their implementation of various components, they have sections, sometimes whole classes, dedicated to working around particular quirks in WebKit, Opera, IE6... Their code is very clear and well commented, often including not just "what" but also "why".

How effective this approach is will depend on how good you are at zeroing in on relevant code (in Java), understanding it and moving the implementation of the essentials to your own code.

Carl Smotricz
REALLY??? Is the IE6 z-index issue resolved? How???
erikkallen
In all likelihood more worked around than resolved. But GWT has menus, pop-ups, layers... all kinds of z-order stuff, and it all works on IE6 as far as I know. I only worked with it for a couple of weeks so I don't have deep experience, and I chose not to support IE6, so I have no personal exp to relate, unfortunately.
Carl Smotricz
We're talking code with full JavaScript control of the DOM here, so I wouldn't put it past them to have removed and re-assembled some DIVs, or dynamically tweaked z-layers, or something. Some of these tricks may be infeasible if JS is not available.
Carl Smotricz
More info on this: It seems the workaround involves nasty stuff like popping up an `iframe`. Some info on a JQuery implementation is here: <http://ajaxian.com/archives/work-around-the-z-index-issue-with-heavyweight-ie-components> and/or you can Google for "iframe shim". Nasty stuff, all that!
Carl Smotricz
+1 Thanks for the suggestion. I have a solution that works now that doesn't require quite that much work ;0)
Mark Brittingham