问题
父div为fixed,子div为absolute,设置bottom:0,并不生效,如下代码
在线运行查看
<div class='dialog'>
<div class='dialog-cover-layer'></div>
<div class="dialog-content">
<div class="content-top">top</div>
<ul class='content-middle'>
<li>...</li>
</ul>
<div class='content-bottom'>bottom</div>
</div>
</div>
<style>
.dialog-cover-layer {
position: fixed;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
opacity: 0.3;
background: #000000;
}
.dialog-content {
position: fixed;
top: 56px;
bottom: 59px;
left: 0;
right: 0;
z-index: 2;
width: 500px;
height: auto;
margin: 0 auto;
background: #fff;
overflow-y: auto;
padding-top: 50px;
padding-bottom: 50px;
box-sizing: border-box;
}
.content-top {
position: absolute;
left: 0;
top: 0;
z-index: 9999;
width: 100%;
height: 50px;
background-color: red;
}
.content-bottom {
position: absolute;
left: 0;
bottom: 0;
z-index: 9999;
width: 100%;
height: 50px;
background-color: blue;
}
</style>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…