views:

162

answers:

4

For my understand. I need to put div 2 in front of div 3. How can I do this in IE6 and IE7. All of others browsers works normal. Here is my code.


CSS

    div {
        position:absolute;
    }
    #div1 {
        background:#0F9;
        top:0;
        left:0;
        width:500px;
        height:400px;
    }

    #div2 {
        background:#C00;
        top:20px;
        left:280px;
        width:100px;
        height:100px;
        z-index:3;
    }

    #div3 {
        background:#006;
        top:10px;
        left:10px;
        width:300px;
        height:200px;
        z-index:2;
    }

Código

<div id="div1">
    <div id="div2"></div>
</div>

<div id="div3"></div>
A: 

See http://stackoverflow.com/questions/1156192/internet-explorer-z-index-bug.

You need to explicitly set the z-index for your "#div1". Simply set #div1 { z-index: 0; } and your problem is solved.

http://www.webdevout.net/test?01c

jsumners
This 2 answers do not help me. I need to put div 3 between div1 and div 2. And these answers. One put div1 in front of div3 and the other one duplicate the div and i can´t do that. Someone could help me?
Leo
If I explicitly #div to z-index:0 #div3 will be in front of #div2. This solution do not work.
Leo
Best solution, use flash! :-/
Leo
A: 

Somebody could help me, please.

Leo
+1  A: 

I have tested the following in IE6/7/8, Chrome, and Firefox. This puts #two in between #one and #three

HTML :

<html lang="en">
  <head>
    <title>Test</title>
  </head>
  <body>
    <div id="content">
       <div id="one">One</div>
       <div id="two">Two</div>
       <div id="three">Three</div>
    </div>
  </body>
 </html>

CSS:

 #one{
     background-color: #f1f1f1;
     position: absolute;
     left:105px;
     top:155px;
     z-index: 0;
 }
 #two{
     background-color: #c9c9c9;
     position: absolute;
     left:100px;
     top:145px;
     z-index: 1;
 }
 #three{
       background-color: #888888;
       color: #f1f1f1;
       position: absolute;
       left:95px;
       top:135px;
       z-index: 2;
 }

In Action: http://www.webdevout.net/test?02C

HurnsMobile
But in this way you changed the html and I can´t change. Do you have another solution?
Leo
A: 

Nobody could help me?

Leo
Please, somebody. It´s urgent. :-/
Leo
ok, use flash! :-/
Leo