``
<html>
<head>
<style>
div{
outline: 2px solid;
margin: 5px;
}
/* 以下为整个页面的布局 */
.main{
display:flex;
flex-direction: column;
height:100%;
}
.top, .footer{
height: 50px;
}
/* 以下为中间的body布局 */
.body{
flex:1;
display: flex;
}
.body-main{
flex: 1;
background-color: yellow;
}
.body-left, .body-right{
width: 100px;
}
</style>
</head>
<body>
<div class="main">
<div class="top">标题栏</div>
<div class="body">
<div class="body-left">左边导航栏</div>
<div class="body-main">主内容,自动伸缩</div>
<div class="body-right">右边提示栏</div>
</div>
<div class="footer">页脚栏,使用flex布局</div>
</div>
</body>
</html>
flex布局使用的时候,把父容器用 display:flex 设置为flex容器,里面的3个DIV,把固定大小的2个DIV设置固定的高度、宽度(水平的时候设置宽度,垂直的时候设置高度),把自动伸缩的DIV设置 flex:1 即可。就是这么简单。flex-direction: column 设置3个DIV为垂直方向(设置垂直方向的时候需要设置高度为100%),默认是水平方向。