1、知识储备
2、html代码
<body>
<div class="content">
<div class="middle">middle</div>
<div class="left">left</div>
<div class="right">right</div>
</div>
</body>
3、css代码
<style>
.content {
height: 200px;
/* 为左右留出位置 */
padding: 0 100px;
}
.left {
background-color: pink;
width: 100px;
height: 100px;
/* 左浮动让三者在同一行 */
float: left;
margin-left: -100%;
/* 消除左边间隙 */
position: relative;
left: -100px;
}
.middle {
background-color: gold;
/* 中间自适应 */
width: 100%;
height: 100px;
float: left;
}
.right {
background-color: deepskyblue;
width: 100px;
height: 100px;
float: left;
margin-right: -100px;
}
</style>
效果:
参考: