Reputation: 2615
In my project I have a form with three inputs, and for all I want to use the input-group
and input-group-addon
offered by Bootstrap
. If I use the following code,
<div class="input-group form-group">
<span style="text-align:left;" class="input-group-addon">... vs Frank</span>
@Html.TextBoxFor(model => model.vsFrank, new { @class = "form-control" })
</div>
<div class="input-group form-group">
<span style="text-align:left;" class="input-group-addon"> ... vs any other guy</span>
@Html.TextBoxFor(model => model.vsAnyOther, new { @class = "form-control" })
</div>
<div class="input-group form-group ">
<span style="text-align:left;" class="input-group-addon">... vs any other monster</span>
@Html.TextBoxFor(model => model.vsAnyMonster, new { @class = "form-control" })
</div>
the result looks like this,
Now, I'd like to have the labels of the last two rows lined up, but the one of the first row shorter. If I add some width to them, as follows,
<div class="input-group form-group">
<span style="width:15ch; text-align:left;" class="input-group-addon">... vs Frank</span>
@Html.TextBoxFor(model => model.vsFrank, new { @class = "form-control" })
</div>
<div class="input-group form-group">
<span style="width:25ch; text-align:left;" class="input-group-addon"> ... vs any other guy</span>
@Html.TextBoxFor(model => model.vsAnyOther, new { @class = "form-control" })
</div>
<div class="input-group form-group ">
<span style="width:25ch; text-align:left;" class="input-group-addon">... vs any other monster</span>
@Html.TextBoxFor(model => model.vsAnyMonster, new { @class = "form-control" })
</div>
the result looks like this:
Now the whole first control is shortened! How can I prevent that without giving all the controls explicit width?
Upvotes: 1
Views: 1282
Reputation: 32275
Add a min-width
for the input-group.
CSS
.input-group {
min-width: 100%;
}
HTML
<div class="row">
<div class="col-md-3">
<div class="input-group form-group">
<span style="width:15ch; text-align:left;" class="input-group-addon">... vs Frank</span>
<input class="form-control">
</div>
<div class="input-group form-group">
<span style="width:25ch; text-align:left;" class="input-group-addon">... vs any other guy</span>
<input class="form-control">
</div>
<div class="input-group form-group">
<span style="width:25ch; text-align:left;" class="input-group-addon">... vs any other monster</span>
<input class="form-control">
</div>
</div>
</div>
Upvotes: 1