Cho container:
display:flex;
flex-direction:column;
và cho các phần tử:
flex:1;
Bản demo: https://jsfiddle.net/ugjfwbg4/1/
body {
background-color: red;
height: 100%;
}
.wrap {
height: 100vh;
width: 100%;
padding: 20px;
background-color: yellow;
display:flex;
flex-direction:column;
}
.top {
width: 100%;
height: 50px;
background-color: blue;
}
.mid {
width: 100%;
background-color: green;
flex:1;
display:flex;
flex-direction:column;
}
.left{
flex:1;
width: 50%;
background-color: red;
}
.bottom {
width: 100%;
height: 50px;
background-color: blue;
}
<div class="wrap">
<div class="top"></div>
<div class="mid">
<div class="left">left</div>
</div>
<div class="bottom"></div>
</div>
Cảm ơn John. trên fiddle này: [link] (https://jsfiddle.net/ugjfwbg4/2/) div màu đỏ bên trong của màu xanh lá cây không kéo dài đến 100% bạn có thể giải thích? –
Làm theo quy tắc css đối với thùng chứa và trẻ em như trước. https://jsfiddle.net/ugjfwbg4/3/ và xem https://css-tricks.com/snippets/css/a-guide-to-flexbox/ – John