Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap - Vertically align input with label inside control-group

<div class="control-group">
    <label class="control-label ">Date of purchase as detailed on your receipt</label>
    <div class="controls">
        <div class="input-append">
            <select name="invoice_date" value="2013-06-28" required="required">
                <option value="">Please Select</option>
            </select>
            <button type="button" class="btn info btn-primary" data-help="invoice_date">i</button>
        </div>
    </div>
</div>

I tried a few solutions and one kind of worked using position absolute, but this affected other areas of bootstrap in particular when it gets responsive.

http://jsfiddle.net/tGZLd/

I am trying to get the input to line up with the center of the label that has been pushed over multiple lines but in the best practice of bootstrap.

Or should I simply give up and force it to display a full width label with the input underneath?

Any insight would be great, thanks!

like image 597
Hard-Boiled Wonderland Avatar asked Jul 24 '13 22:07

Hard-Boiled Wonderland


1 Answers

How about overriding Bootstrap's styles and using display:inline-block; instead of floats for the positioning, then you can use vertical-align to center the label:

.form-horizontal .control-label {
    display: inline-block;
    vertical-align: middle;
    float: none;
}
.form-horizontal .controls {
    display: inline-block;
    margin-left: 20px;
}

Example fiddle

like image 63
omma2289 Avatar answered Oct 14 '22 21:10

omma2289