http://madisonlane.businesscatalyst.com
I'm trying to get the div#sign-post to sit above the div#bottom. This works fine in all browsers except IE6 & IE7. Can anyone see what the problem is here?
Also IE6 is displaying an additional 198px to the top of div#bottom.
the only reliable solution is, to put the top elements below in the code and then push them over the other stuff with absolute positioning.
e.g. Wordpress: put the navigation in the footer file, but still inside the page wrapper.
might also bring some advantages for search engines, because they can directly start with the content, without crawling through the menu first...
UPDATE: I need to correct myself. While putting the element below and then pushing it over is still the easiest way, there are certain cases when this is not possible in reasonable time. Then you have to make sure that each and every parent element has some kind of positioning and some senseful z-index. Then the z-index should work again even in IE7.
Welcome, I solved the problem with:
Agree with validator comment - validating usually helps. But, if it doesn't heres a few pointers for z-index in IE:
1) elements who's z-index you're manipulating should be on the same level ie. you should be setting the z-index of #bottom and #body
if this is not feasible then
2) IE sometimes wont apply the z-index correctly unless the elements ou are applying it to have a
position:relative
. Try applying that property to #bottom and #body (or #signpost)let me know how that works out
Darko
Looks to me like you have some malformed HTML in there. I tried counting, and perhaps I lost count of the opening and closing tags, but it looks like div#container isn't closed. Try running your page through a validator (such as W3C's HTML Validator, or something) and fixing some of the errors. That's helped me with these sorts of problems in the past. Good luck!
I've recently had an ongoing problem displaying one layer above another. In my case I was programmatically creating two layers in Javascript, one for diaplaying a custom control and one for creating a full screen layer behind it. FF was fine, bu IE displayed the full screen layer always on top of everything else.
After numerous trawls over the interweb, trying everyone's suggestions, the only way I eventually get it working was to remove
position:
attributes from both layers, and tweak themargin-top:
attribute until I got a satisfactory result.A bit of a hash, but it works and it'll be fine until IE 8 sorts out all of the current bugs......
Most of the answers here are wrong; some work, but not for the reason they state. Here is some explanation.
This is how z-index should work according to the spec:
z-index
value to any element; if you don't, it defaults toauto
position
attribute different from the defaultstatic
) with az-index
different fromauto
create a new stacking context. Stacking contexts are the "units" of overlapping; one stacking context is either completely above the another (that is, every element of the first is above any element of the second) or completely below it.z-index
value have that value as a stack level, other elements inherit from their parents. The element with the higher stack level is displayed on top. When two elements have the same stack level, generally the one which is later in the DOM tree is painted on top. (More complicated rules apply if they have a differentposition
attribute.)In other words, when two elements have
z-index
set, in order to decide which will show on top, you need to check if they have any positioned parents which also havez-index
set. If they don't, or the parents are common, the one with the higher z-index wins. If they do, you need to compare the parents, and thez-index
of the children is irrelevant.So the
z-index
decides how the element is placed compared to other children of its "stacking parent" (the closest ancestor with az-index
set and aposition
ofrelative
,absolute
orfixed
), but it doesn't matter when comparing to other elements; it is the stacking parent'sz-index
(or possibly thez-index
of the stacking parent's stacking parent, et cetera) which counts. In a typical document where you usez-index
only on a few elements like dropdown menus and popups, none of which contains the other, the stacking parent of all the elements which have az-index
is the whole document, and you can usually get away with thinking of thez-index
as a global, document-level ordering.The fundamental difference with IE6/7 is that positioned elements start new stacking contexts, whether they have
z-index
set or not. Since the elements which you would instinctively assignz-index
values to are typically absolutely positioned and have a relatively positioned parent or close ancestor, this will mean that yourz-index
-ed elements won't be compared at all, instead their positioned ancestors will - and since those have no z-index set, document order will prevail.As a workaround, you need to find out which ancestors are actually compared, and assign some z-index to them to restore the order you want (which will usually be reverse document order). Usually this is done by javascript - for a dropdown menu, you can walk through the menu containers or parent menu items, and assign them a
z-index
of 1000, 999, 998 and so on. Another method: when a popup or dropdown menu becomes visible, find all its relatively positioned ancestors, and give them anon-top
class which has a very high z-index; when it becomes invisible again, remove the classes.