<div class="one"><div>
<div class="parent">
<div class="child">
</div>
</div>
是否可以让class为1的div高于父div但低于子div?
答案 0 :(得分:0)
是的,有可能
<强> HTML 强>
<div class="one"> 1 </div>
<div class="parent">
parent
<br/> <br/> <br/> <br/>
<div class="child">
child
</div>
</div>
<强> CSS 强>
.one{
background:yellow;
height:30px;
width:100px;
position:absolute;
top:50px;
}
.parent{
background:green;
height:300px;
width:100px;
}
.child{
background:black;
height:100px;
width:60px;
}
答案 1 :(得分:0)
好的,那是怎么回事:
<强> HTML 强>
<div class="one">One
</div>
<div class="parent">Parent
<div class="child">Child
</div>
</div>
<强> CSS 强>
.one {
margin-top: 100px;
background: blue;
height: 200px;
width: 100px;
}
.parent {
background: yellow;
height: 100px;
width: 100px;
position: relative;
}
.child {
position: absolute;
background: green;
height: 100px;
width: 100px;
top: -300px;
}
查看here。
答案 2 :(得分:0)
这种方式更短:
.one { margin-top: 100px; }
.child { width: 100%; height: 100px; position: absolute; top: 0; }