使用 flex 布局实现中间自适应两边固定的三列布局!
代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
*{
margin:0;
padding:0;
}
body{
display:flex;
flex-direction:column;
}
header,footer{
flex:0 0 80px;
background-color:#6ff;
}
.main{
display:flex;
flex:1;
height:200px;
}
.left,.right{
background-color:#6fa;
flex:0 0 100px;
}
.left{
order:-1;
}
.middle{
background-color:#fbf;
flex:1;
}
</style>
</head>
<body>
<header>header</header>
<div class = "main">
<div class = "middle">middle</div>
<div class = "left">left</div>
<div class = "right">right</div>
</div>
<footer>footer</footer>
</body>
</html>