Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap - input-group-addon alignment

I am currently making a form, but if I add a input-group with input-group-addon, that input will become unaligned with the rest.

The addon seems to affect the width of the input.

Part of my code:

<div class="form-group">
    <label for="inputName" class="col-sm-2 control-label">Name</label>
    <div class="col-sm-3">
        <input type="text" class="form-control" id="inputName" placeholder="Name" name="name" value="{{name}}" onblur="isEmpty(this)">
    </div>
</div>


<div class="form-group">
    <label for="inputLastSeen" class="col-sm-2 control-label">Last Seen</label>
    <div class="col-sm-3 input-group date form_datetime"
         data-link-field="inputLastSeen">
        <input type="text" class="form-control" value="" readonly>
        <span class="input-group-addon">
            <span class="glyphicon glyphicon-th">
            </span>
        </span>
    </div>
    <input type="hidden" id="inputLastSeen" name="lastSeen" value="">
</div>

enter image description here

** I am using http://www.malot.fr/bootstrap-datetimepicker/demo.php for the DateTimePicker

like image 987
user3675227 Avatar asked May 30 '14 01:05

user3675227


1 Answers

Read the input group docs:

Don't mix with other components

Do not mix form groups or grid column classes directly with input groups. Instead, nest the input group inside of the form group or grid-related element.

(emphasis added)

So instead of:

<div class="col-sm-3 input-group">

You want:

<div class="col-sm-3">
    <div class="input-group">
like image 88
cvrebert Avatar answered Jan 01 '23 10:01

cvrebert