<分区>
我遇到了棘手的问题,我需要在一行中放置两个 div(left,right),right 必须已修复宽度,但 left 必须填充可用空间,换句话说:left div 必须有 100% - X 像素,right div 应该是 X 像素.
重点:没有位置相对/绝对 hack。
有什么办法可以达到这个效果。我尝试了很多方法,但都没有成功。
这里是 jsfiddle
标记
<html>
<head>
<title></title>
</head>
<body>
<style>
.container {
/* container don't matter */
width: 500px;
background-color: bisque;
height: 50px;
}
.container .left {
/* display: inline-block; */
margin-right: 50px;
background-color: burlywood;
height: 50px;
}
.container .right {
float: right;
background-color: chartreuse;
width: 50px;
height: 50px;
}
</style>
<div class="container">
<div class="left">
fill free space (100% - right)
</div>
<div class="right">
fixed width
</div>
</div>
</body>
</html>