主要是实现 首尾固定 中间自适应 以及 左右固定 中间自适应的布局。
横向三段式主要采用flex,纵向三段式采用position:absolute布局。
最终实现效果
<!DOCTYPE html>
<html>
<style type="text/css">
body,html{
height:100%;
margin:0;
}
.page{
height: 100%;
margin:0;
}
.top{
position: absolute;
height: 50px;
top:0;
left: 0;
background-color: red;
width:100%;
}
.main{
/*实现纵向自适应*/
width:100%;
position: absolute;
margin-top:50px;
height: calc(100% - 100px);
/*实现横向自适应*/
display: flex;
}
.center{
flex:1;
background: yellow
}
.left{
width:250px;
background: green;
}
.right{
width: 250px;
background: green;
}
.bottom{
position: absolute;
height: 50px;
bottom:0;
left: 0;
background-color: red;
width:100%;
}
</style>
<head>
<title></title>
</head>
<body>
<div class='page'>
<div class='top'>1</div>
<div class='main'>
<div class='left'>left</div>
<div class='center'>center</div>
<div class='right'>right</div>
</div>
<div class='bottom'></div>
</div>
</body>
</html>`