ui-select : set width in Bootstrap grid system

user1260928 picture user1260928 · Jan 30, 2015 · Viewed 8.6k times · Source

I have a form with a ui-select in a bootstrap grid. I want my ui-select to be as wide as the input below it. Here is my code

<div class="col-md-12">
   <div class="col-md-6 form-group">
        <label class="col-md-4" style="text-align:right;">Pays</label>
        <div class="col-md-8">
            <ui-select ng-model="adresse.pays" theme="select2" ng-disabled="disabled" ame="pays">
                <ui-select-match placeholder="Sélectionnez un pays..." allow-clear>{{$select.selected.nom}}</ui-select-match>
                <ui-select-choices repeat="pays in payss | propsFilter: {nom : $select.search}">
                    <div ng-bind-html="pays.nom | highlight: $select.search"></div>
                </ui-select-choices>
            </ui-select>
        </div>
    </div>
    <div class="col-md-6">
        <label class="col-md-4" style="text-align:right;">Mail</label>
        <input type="text" class="col-md-3 input-sm"
            ng-model="adresse.mail">
    </div>
</div>
<div class="col-md-12">
    <div class="form-group col-md-6">
        <label class="col-md-4" style="text-align:right;">Code adresse client</label>
        <input type="text" class="col-md-8 input-sm"
            ng-model="adresse.codeAdresseClient" name="codeAdresse">
    </div>
    <div class="form-group col-md-6">
        <label class="col-md-4" style="text-align:right;">Interlocuteur</label>
        <input type="text" class="col-md-3 input-sm"
            ng-model="adresse.interlocuteur" name="interlocuteur">
    </div>
</div>  

This code produces this: enter image description here

If someone knows how to do that... Thanks in advance.

Answer

Istv&#225;n B&#233;k&#233;si picture István Békési · Apr 3, 2015

My suggestion is to either

  • use bootstrap theme (instead of select2), or
  • simply set width to 100%

Check this plunk: http://plnkr.co/edit/9mI8nO?p=preview

<ui-select ng-model="person.selected" theme="bootstrap">
  ...
</ui-select>

<ui-select ng-model="person.selected" theme="select2" style="width:100%">
  ...
</ui-select>