在7+和opera中的z-index问题

时间:2011-05-25 18:01:32

标签: browser html positioning z-index

这是html:

<div id = "parent">
   <div id = "one" ></div>
   <div id = "two" ></div>
</div>

的CSS:

#parent
{
  position:    relative;
}
   #parent > #one
   {
     position:  absolute;
     z-index:   10;
     top:       50px;
     left:      50px;  
     width:     100px;
     height:    100px;
     background:  white;        
   }
   #parent > #two
   {
     position:  absolute;
     z-index:   5;
     top:       50px;
     left:      50px;
     height:    50px;
     width:     50px;
     background: black;
   }

ie7 +和opera中的问题是div“one”不重叠div“two”,为什么会这样?

1 个答案:

答案 0 :(得分:0)

尝试使用以下内容:

<div id = "parent">
   <div class= "one" ></div>
   <div class= "two" ></div>
</div>
css:

#parent
{
  position:    relative;
width: 150px;
height: 150px;
background: yellow;
}
   #parent  .one
   {
     position:  absolute;
     z-index:   10;
     top:       50px;
     left:      50px;  
     width:     100px;
     height:    100px;
     background:  white;        
   }
   #parent .two
   {
     position:  absolute;
     z-index:   5;
     top:       50px;
     left:      50px;
     height:    50px;
     width:     50px;
     background: black;
   }

希望你能得到线索