I have two divs side by side. The firs one contains a text field that can be rather lengthy and another one contains a number that is short.
I need the first div to occupy all available space without stretching parent and clipping if neccessary. Ant it should take width of a second div into account. So if length of the text is short, then two divs should be side by side, but if text is long, then the first one will be clipped and the second one will be pushed all the way to the right.
Here is approximate table layout:
<div id="container">
<div id="row">
<span id="text">Short text</span><span id="value">123</span>
</div>
<div id="row">
<span id="text">A bit longer text</span><span id="value">555</span>
</div>
<div id="row">
<span id="text">A very very very very very very very very long text</span><span id="value">555</span>
</div>
</div>
And corresponding CSS:
#container {
border: 1px solid #000000;
width: 300px;
}
#row {
display: inline-block;
border: 1px solid #000077;
width: 100%;
clear: both;
}
#text {
display: inline-block;
border: 1px solid #007700;
}
#value {
display: inline-block;
border: 1px solid #770000;
}
Here is a jsfiddle template illustrating what I need. A very long text line should be clipped and 555 should be placed next to it on the same line so that entire construction fits into specified 300px (number is arbitrary, it will be defined by other elements in real life and it is not known in advance).