[css] 外層有一個自適應高度的div,里面有兩個div,一個高度固定300px,另一個怎么填滿剩余的高度?
可以設定外層自適應高度的容器為flex布局,利用flex-basis屬性即可實作自動填滿剩余高度;代碼如下:
.container{
display: flex;
flex-flow: column nowrap;
height: 500px;
border: 2px dashed orange;
}
.area1 {
flex-basis: 300px;
background-color: lightblue
}
.area2 {
flex: 1;
background-color: darkcyan;
}
<section class="container">
<div class="area1">300px</div>
<div class="area2">other</div>
</section>
個人簡介
我是歌謠,歡迎和大家一起交流前后端知識,放棄很容易,
但堅持一定很酷,歡迎大家一起討論
主目錄
與歌謠一起通關前端面試題
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/262057.html
標籤:其他
上一篇:vue 實作 markdown書寫博客 showdown
下一篇:CSS星星打分特效
