0

I'm making an output field with labels in front of them. Each label has a different width due to the label name and I want to let the output field take up the remaining width between the label and the next label. Now the output field is only growing in width if there is text in the field.

HTML:

<div class="row">
    <div class="div triple"><label for="bedrijf">Bedrijfsnaam</label>
        <span class="output" id="bedrijf"></span></div>
    <div class="div triple"><label for="functie">Functie</label>
        <span class="output" id="functie"></span></div>
    <div class="div triple"><label for="kvk">KVK-nummer</label>
        <span class="output" id="kvk"></span></div>
</div>

CSS:

.row {
    float: left;
    width: 100%;
}
.triple {
    width: 33%;
}
.output {
    width: auto;
    text-align: left;
    color: #f57f43;
    display: inline-block;
}
Laurens Smid
  • 511
  • 3
  • 15

1 Answers1

0

The question has been asked many times here. Google can really help you know ;).
The interesting link is here: Expand a div to take the remaining width
The solution is there

.row {
    width: 100%;   
}
.triple {
    width: 33%;
    float: left;
}

.output {
    height: 20px;
    vertical-align: middle;
    overflow: hidden;
    text-align: left;
    color: #f57f43;
    display: block;
    width: auto;
    background-color: black;
}
label{display: inline-block; float: left;}

http://jsfiddle.net/piiantom/d5w1ntaf/

Community
  • 1
  • 1
PIIANTOM
  • 1,311
  • 11
  • 20