Jump to content

multiple position relatives in IE


jonniejoejonson

Recommended Posts

The following should produce a green square over the top of both a yellow stripe and an orange stripe.

Please note this is not my actual problem but it is the principal cause of the problem i am having.

 

In explorer the green square is positioned under the orange stripe.. this should not be so.. any ideas why?.. if i remove the position relative from the orange stripe it works... however i need the orange stripe to be position relative.... any ideas...

 

Just saying Explorer is *beep* is not an acceptable answer!! even though it may be correct...

 

<div style="position:relative; float:left; width:100%; height:100px; background:yellow;">
<div style="position:absolute; z-index:1000000; top:0; left:0; width:250px; height:250px; background:green;"></div>
</div>

<div style="position:relative; float:left; width:100%; height:100px; background:orange;">
</div>

Link to comment
Share on other sites

Internet explorer (you didn't mention which version by the way) has issues with the z-index. You have set the z-index on the child element (green), but the parent element (yellow) has the same z-index as it's sibling (orange). Since the sibling (orange) is later in the document, it takes a higher precedence than the element before it. As the parent (yellow) is relatively positioned, The z-index on the child (green) is only relevant to it's own siblings (siblings of the green, if any existed).

 

The secret is to set a z-index of one on the parent (yellow) element.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.