原理:
1)左右两个盒子,左侧盒子宽度固定,右侧盒子宽度为100%
- 2)为左侧设置绝对定位position: absolute;
- 3)在右侧盒子中添加子盒,为子盒设置padding-left属性,值为左侧盒子宽度
代码:
<style>
.left {
width: 300px;
min-height: 100px;
background-color: green;
position: absolute;
}
.right {
width: 100%;
min-height: 100px;
background-color: red;
}
.content {
padding-left: 300px;
}
</style>
</head>
<body>
<div class="wrap">
<div class="left"></div>
<div class="right">
<div class="content">
</div>
</div>
</div>
</body>
结果: