我希望在#green
div 下方出现 #blue
div
#blue
div 使用了 margin-top : -10px; 属性
<style>
#red{
width: 400px;
border: 1px solid red;
}
#green{
width: 100%;
height: 100px;
background-color: green;
border-bottom: 2px solid yellow;
z-index: 2;
}
#blue{
width: 100%;
height: 100px;
background-color: blue;
border-top: 2px solid brown;
margin-top: -10px;
z-index: 1;
}
</style>
<div id="red">
<div id="green">
</div>
<div id="blue">
</div>
</div>
position:relative;
应该可以使z-index
起作用,但我不确定它是否能在所有浏览器上都良好地工作(我在考虑早期版本的IE ...) - Matt Gibson