0

I'm trying to align two buttons to ad input field but I end up messing everything every single time.
I've already aligned an input field to a single button, but I'm not able to add a second button.

This is the html (I'm using some angularjs):

<div class="row">
    <div class="col-lg-12">
        <form class="form" ng-submit="vm.reCreateTree(ricercaSecondario)" ng-init="aggiornaRicercaPratica()">
            <div class="input-group">                               
                <input type="text" ng-model="vm.cercaSecondario" class="form-control" placeholder="{{getTestoPlaceholderRicerca(ricercaPraticaSecondario)}}" required="required" ng-disabled="disabilitaRicercaSecondaria()">
                   <div class="input-group-btn">
                       <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>  
                       <button class="btn btn-default" type="submit"
                            tooltip="Espandi filtri di ricerca" tooltip-placement="bottom"
                            ng-click="toggleRicerca()" ng-show='user.ambitoSelezionato.nome == "Clienti-Polizze"'>
                       <i ng-class="{'fa fa-caret-up': showEspandiRicerca, 'fa fa-caret-down': !showEspandiRicerca}"></i>
                       </button>
                  </div>    
           </div>                            
        </form>
    </div>
</div>

This is a screenshot of the result: enter image description here

As you can see the two button are not in the same line as the input field and they are also uneven (speaking about dimensions)...
Any help?!

UPDATE: updated the code (thanks to Mukesh Ram) but the buttons still have two different sizes..

enter image description here

3
  • You can use Bootstrap's grid system and input groups cto align in single line with same width. Commented Jul 15, 2016 at 9:01
  • So you need to search icon and arrow icon button have some width? Right? Commented Jul 15, 2016 at 9:41
  • yeah. I'd like them to have the same width Commented Jul 15, 2016 at 9:49

2 Answers 2

1

You can have multiple buttons inside a single .input-group-btn. Like this:

<div class="col-lg-6"> 
    <div class="input-group">
       <input type="text" class="form-control" aria-label="Text input with multiple buttons"> 
       <div class="input-group-btn"> <!-- add button in this div -->
         <button type="button" class="btn btn-default" aria-label="Help">
            <span class="glyphicon glyphicon-question-sign"></span>
         </button>
         <button type="button" class="btn btn-default">Action</button> 
      </div>
   </div>
</div>
Sign up to request clarification or add additional context in comments.

3 Comments

I'm upvoting this because you solved half of my problem. The buttons still have two different sizes...
So, you have to fixed the width of buttons. Like this: .form .input-group-btn button{ width:39px;}
I don't use css and there are other input-group-btn so I can't place it in header. Isn't there a property that takes care of the width of the buttons?!
1

One other way :
form-inline and form-group

Bootply : http://www.bootply.com/uHEpGIOLwY

 <div class="row">
      <div class="col-lg-12">
        <form class="form-inline" ng-submit="vm.reCreateTree(ricercaSecondario)" ng-init="aggiornaRicercaPratica()">
          <div class="form-group">
            <input type="text" ng-model="vm.cercaSecondario" class="form-control" placeholder="{{getTestoPlaceholderRicerca(ricercaPraticaSecondario)}}" required="required" ng-disabled="disabilitaRicercaSecondaria()">
            <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
            <button class="btn btn-default" type="submit" tooltip="Espandi filtri di ricerca" tooltip-placement="bottom" ng-click="toggleRicerca()" ng-show='user.ambitoSelezionato.nome == "Clienti-Polizze"'>
              <i ng-class="{'fa fa-caret-up': showEspandiRicerca, 'fa fa-caret-down': !showEspandiRicerca}"></i>
            </button>
          </div>
        </form>
      </div>
    </div>

1 Comment

I've a preference for @MukeshRam answer... But just for the diversity of answers, I post this one....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.