首页 > 代码库 > 两列布局,一列定宽,一列宽度自适应

两列布局,一列定宽,一列宽度自适应

方法一:

body{
margin: 0;
}
.container{
height: 300px;
overflow: hidden;
}
.left{
width: 200px;
height: 300px;
background: red;
position: absolute;
left:0;
top: 0;
}
.right{
margin-left:200px;
width: 100%;
height: 300px;
background: green;
}

<div class="container">
<div class="left"> </div>
<div class="right"> </div>
</div>

方法二:

body{
margin:0;
}
#wrapper{
height: 300px;
overflow: hidden;
}
.left{
width: 200px;
height: 100%;
background: red;
float: left;
}
.right{
width: 100%;
height: 100%;
float: right;
background: green;
margin-right: -200px;
}

<div id="wrapper">
<div class="left">
</div>
<div class="right">
</div>
</div>