Getting wrong height in bootstrap input-group

2.3k Views Asked by At

I'm trying to get a beautiful form with input-group Bootstrap 3.3.7 class, but something is wrong.

I think I have coded right input-group structure: the main div contains other three elements, an input-group-addon, an input-form and finally an input-group-button (with things inside).

My problem is that the third element broke the height main div, resulting in an input-group-addon few pixels bigger than other input-group elements.

My code:

<div class="col-xs-12 col-md-6">
    <div class="input-group">
        <span class="input-group-addon" id="sizing-addon2">Artículo</span>
        <ng2-completer [(ngModel)]="bus.articuloName" (selected)="artSelected($event)" [matchClass]="'match'" [placeholder]="'Nombre de Articulo'" [datasource]="artService" [textNoResults]="'No hay coincidencias'"></ng2-completer>
        <span class="input-group-btn">
            <button class="btn btn-default" type="button" (click)="init('art')">
                X
            </button>
        </span>
    </div>
</div>

My results:

enter image description here

Without input-group-button, the code works fine, but I really need this third element. I tried with glyphicons and btn-link instead btn-default... And I get difference wrong heights (a not exactly same result that the picture).

By the way, I have 7 input-group in the form and 4 work properly and 3 have this problem, so there should not be a CSS inherit problem or something like that.

Anybody knows where is the problem?

1

There are 1 best solutions below

5
On BEST ANSWER

Does your input get rendered by angular with a class of form-control?

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<div class="col-xs-12 col-md-6">
  <div class="input-group">
    <span class="input-group-addon">Artículo</span>

    <input type="text" class="form-control" placeholder="Nombre de Articulo">

    <span class="input-group-btn">
        <button class="btn btn-default" type="button">X</button>
    </span>

  </div>
</div>