我想构建一个2列DIV布局。其中一列应右对齐并自动调整大小,另一列应填充左侧剩余空间。
答案 0 :(得分:5)
喜欢这个http://jsfiddle.net/UNgcd/2/?
HTML:
<div class='wrap'>
<div class='right'>
<p>some text goes here for auto width</p>
</div>
<div class='left'>
<p>this takes up remaining space to the left</p>
</div>
</div>
CSS:
.right {
background-color: red;
float: right;
width: auto;
}
.left {
background-color: yellow;
overflow: hidden;
}
答案 1 :(得分:1)
HTML:
<div id="right">Auto sized right div</div>
<div id="left">Auto filling left div</div>
CSS:
#left{
overflow: hidden;
}
#right{
float: right;
}