是否有可能把一个div放在另一个没有背景,没有绝对位置?这是一个简化的响应式设计。内容将改变宽度为%。所以在这种情况下,我认为我不能使用绝对定位?有没有办法让div跨越其他人?没有绝对,没有背景
在这里我使用相对定位,但Z指数似乎并没有工作。我不懂为什么?
这里的例子来打:http://jsfiddle.net/WMXMW/1/
CSS:
#content{
margin:0 auto;
width:40%;
overflow:hidden; /* a way of clearing float */
text-align:center;
}
#text{
margin:0 auto;
text-align:justify;
}
#menuTrans{
position:relative;
margin:0 auto;
z-index:1;
display:inline-block;
}
#blueTrans{
float:left;
width:50px; height:50px;
opacity:0.5;
z-index:0;
background:blue;
}
#redTrans{
float:left;
width:50px; height:50px;
opacity:0.5;
z-index:0;
background:red;
}
#menu{
margin:0 auto;
z-index:0;
display:inline-block;
}
#blue{
float:left;
width:50px; height:50px;
z-index:0;
background:blue;
}
#red{
float:left;
width:50px; height:50px;
z-index:0;
background:red;
}
HTML:
<div id="content">
<div id="text">
some text some text some text
some text some text some text
some text some text some text
some text some text some text
some text some text some text
some text some text some text
some text some text some text
some text some text some text
some text some text some text
</div>
<div id="menu">
<div id="red"> </div>
<div id="blue"> </div>
</div>
<div id="menuTrans">
<div id="redTrans"> </div>
<div id="blueTrans"> </div>
</div>
</div>
你可以使用-ve margin – BK004 2013-04-28 09:14:54
这样的事情? http://jsfiddle.net/eugip9/sS2WX/ – Pigueiras 2013-04-28 09:20:34