核心记忆点:
* 外层盒子加padding且自适应,中间盒子width100%,左右盒子相对定位负值。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.left {
position: relative;
left: -200px;
width: 200px;
height: 500px;
background: red;
float: left;
margin-left: -100%;
}
.right {
position: relative;
right: -300px;
width: 300px;
height: 500px;
background: blue;
float: left;
margin-left: -300px;
}
.mid {
width: 100%;
height: 500px;
background: yellow;
float: left;
}
.content {
padding: 0 300px 0 200px;
}
</style>
</head>
<body>
<div class="content">
<div class="mid"></div>
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>