- 采用浮动的方式
<!DOCTYPE>
<html>
<head>
<meta charset="utf-8">
<title>三栏布局</title>
<style>
*{
padding: 0;
margin: 0;
}
#wrap1{
margin: 0 100px;
}
#wrap div{
height: 300px;
}
#wrap .left{
float: left;
200px;
background: green;
}
#wrap .content{
margin: 0 200px;
background: red;
}
#wrap .right{
float: right;
200px;
background: yellow;
}
</style>
</head>
<body>
<div id="wrap">
<div class="left"></div>
<div class="right"></div>
<div class="content"></div>
</div>
</body>
</html>
- 采用flex方式
<!DOCTYPE>
<html>
<head>
<meta charset="utf-8">
<title>三栏布局</title>
<style>
*{
padding: 0;
margin: 0;
}
#wrap{
margin: 20px 100px;
display: flex;
flex-flow: row nowrap;
}
#wrap div{
height: 300px;
}
#wrap .left{
flex-grow: 0;
200px;
background: green;
}
#wrap .content{
flex: 1 1 auto;
background: red;
}
#wrap .right{
flex-grow: 0;
200px;
background: yellow;
}
</style>
</head>
<body>
<div id="wrap">
<div class="left"></div>
<div class="content"></div>
<div class="right"></div>
</div>
</body>
</html>
目前感觉这两种方式比较实用,欢迎补充