Using Calc
There are a couple of different solution to this. One of which would be to use the calc function.
The calc() function allows mathematical expressions with addition
(‘+’), subtraction (‘-’), multiplication (‘*’), and division (‘/’) to
be used as component values. The ‘calc()’ expression represents the
result of the mathematical calculation it contains, using standard
operator precedence rules. It can be used wherever ,
, , , , or values are
allowed. Components of a ‘calc()’ expression can be literal values,
‘attr()’ or ‘calc()’ expressions, or values that resolve
to one of the preceding types.
.div1 {
height: 16px;
background: grey;
width: 200px;
float: left;
}
.div2 {
height: 16px;
float: left;
background: lightblue;
width: calc(100% - 200px);
}
<div class="div1"></div>
<div class="div2"></div>
Using Display:Table
You could also use the display: table
option. note: this is not using tables
.wrap {
display: table;
width: 100%;
}
.div1 {
height: 16px;
background: grey;
width: 200px;
display: table-cell;
}
.div2 {
height: 16px;
background: lightblue;
display: table-cell;
}
<div class="wrap">
<div class="div1"></div>
<div class="div2"></div>
</div>