Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css absolute position inside relative position not overlapping

I've been having problems trying to get my website to be crossbrowser.. in IE6 I have a container with relative positioning, and inside there is a absolute div, which has negative top and left, but instead of going on top of the relative div, is going underneath looking like this:

        ++++++++++++++++++++++
        +     container      +
        +++++++++++++er      +
        +llo        +er      +
        +rld        +er      +
        +++++++++++++er      +
        +     container      +
        +     container      +
        ++++++++++++++++++++++

insted of:

        ++++++++++++++++++++++
        +     container      +
  +++++++++++++++++++er      +
  +     hello       +er      +
  +     world       +er      +
  +++++++++++++++++++er      +
        +     container      +
        +     container      +
        ++++++++++++++++++++++

in all other browser im using just static positioning for container and absolute position for the hello world div, and is working just fine, but in ie6 the absolute div was weird positioning and no matter how top or left i gave it it didnt move, so I thought about doing this for IE6, but im having the problem describe above.

like image 478
Gmo Avatar asked Jun 04 '11 06:06

Gmo


2 Answers

A combination of position relative with position absolute:

#container
{
    width: 200px;
    margin: 0 auto;
    position: relative;
}
#content
{
    width: 200px;
    position: absolute;
    z-index: 999;
    left: -100px;
    top: 100px;
}

Demo here and screenshot below:

jsfiddle-QBd8P-ie6.

Seems to work in IE6+, FF, Chrome.

like image 142
Salman A Avatar answered Nov 15 '22 04:11

Salman A


What's wrong with Z-Indexing ???

If you go along the lines of what this guy has done here; http://brenelz.com/blog/squish-the-internet-explorer-z-index-bug/

it should work fine for you.

like image 20
Reconix Avatar answered Nov 15 '22 05:11

Reconix