嗯:
bottom: Npx
并将绿色div与红色div放在同一容器中。因为我不知道red div和的大小。top: Npx
并将其放置在与橙色div相同的容器中,因为如果设备高度小于200px,包装器(橙色div)的已知高度为200px。bottom: 0
,因为它具有滚动条。
.wrapper {
background-color: #ff8000;
height: 150px;
display: flex;
position: relative;
padding: 10px;
flex-direction: column;
}
.unkown-height-top {
background-color: #00ff00;
position: absolute;
width: calc(100% - 20px);
bottom: 40px; /* I don't know the size of bottom div here */
height: 50px; /* random*/
}
.unkown-height-bottom {
background-color: #ff0000;
height: 40px; /* random */
flex-shrink: 0;
}
.top-bellow {
flex-shrink: 1;
overflow-y: scroll;
background-color: blue;
}
<div class="wrapper">
<div class="top-bellow">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></div>
<div class="unkown-height-top"></div>
<div class="unkown-height-bottom"></div>
</div>
答案 0 :(得分:1)
您可以将其放在红色div内并使用bottom:100%
.wrapper {
background-color: #ff8000;
height: 150px;
display: flex;
padding: 10px;
flex-direction: column;
}
.unkown-height-top {
background-color: #00ff00;
position: absolute;
width: 100%;
bottom: 100%;
height: 50px; /* random*/
}
.unkown-height-bottom {
background-color: #ff0000;
height: 40px; /* random */
flex-shrink: 0;
position: relative;
}
.top-bellow {
flex-shrink: 1;
overflow-y: scroll;
background-color: blue;
}
<div class="wrapper">
<div class="top-bellow">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></div>
<div class="unkown-height-bottom">
<div class="unkown-height-top"></div>
</div>
</div>