html - Bootstrap buttons and input on one row while input stretching to fill space horizontally? -


i'm having trouble trying align boostrap buttons , input on 1 line, having input stretching horizontally while snuggling against buttons.

here different attempts: button & input alignment

in case #1: button group , input group in same column. input stretches horizontally thrown on next line.

<h2>#1</h2>         <div class="row">             <div class="col-lg-12">                  <div class="btn-group" role="group" aria-label="...">                     <button type="button" class="btn btn-default">default</button>                     <button type="button" class="btn btn-primary">primary</button>                     <button type="button" class="btn btn-success">success</button>                     <button type="button" class="btn btn-info">info</button>                     <button type="button" class="btn btn-warning">warning</button>                     <button type="button" class="btn btn-danger">danger</button>                 </div>                  <div class="input-group">                     <input type="text" class="form-control" aria-label="...">                         <div class="input-group-btn">                             <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">action <span class="caret"></span></button>                         </div><!-- /btn-group -->                 </div><!-- /input-group -->             </div><!-- /.col-lg-12 -->         </div><!-- /.row --> 

in case #2: button group , input group in 2 equal columns, there's gap between two.

<h2>#2</h2>     <div class="row">         <div class="col-lg-6">              <div class="btn-group" role="group" aria-label="...">                 <button type="button" class="btn btn-default">default</button>                 <button type="button" class="btn btn-primary">primary</button>                 <button type="button" class="btn btn-success">success</button>                 <button type="button" class="btn btn-info">info</button>                 <button type="button" class="btn btn-warning">warning</button>                 <button type="button" class="btn btn-danger">danger</button>             </div>         </div><!-- /.col-lg-6 -->         <div class="col-lg-6">             <div class="input-group">                 <input type="text" class="form-control" aria-label="...">                     <div class="input-group-btn">                         <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">action <span class="caret"></span></button>                     </div><!-- /btn-group -->             </div><!-- /input-group -->         </div><!-- /.col-lg-6 -->     </div><!-- /.row --> 

in case #3: more column given input group (ratio 3:9), half of button group gets thrown next line.

<h2>#3</h2>     <div class="row">         <div class="col-lg-3">              <div class="btn-group" role="group" aria-label="...">                 <button type="button" class="btn btn-default">default</button>                 <button type="button" class="btn btn-primary">primary</button>                 <button type="button" class="btn btn-success">success</button>                 <button type="button" class="btn btn-info">info</button>                 <button type="button" class="btn btn-warning">warning</button>                 <button type="button" class="btn btn-danger">danger</button>             </div>         </div><!-- /.col-lg-3 -->         <div class="col-lg-9">             <div class="input-group">                 <input type="text" class="form-control" aria-label="...">                 <div class="input-group-btn">                     <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">action <span class="caret"></span></button>                 </div><!-- /btn-group -->             </div><!-- /input-group -->         </div><!-- /.col-lg-9 -->     </div><!-- /.row --> 

in case #4: button group , input group in same column, wrapped in in-line form. cozy setting, input doesn't stretch feet more.

<h2>#4</h2>     <div class="row">         <div class="col-lg-12">              <form class="form-inline" role="form">                 <div class="btn-group" role="group" aria-label="...">                     <button type="button" class="btn btn-default">default</button>                     <button type="button" class="btn btn-primary">primary</button>                     <button type="button" class="btn btn-success">success</button>                     <button type="button" class="btn btn-info">info</button>                     <button type="button" class="btn btn-warning">warning</button>                     <button type="button" class="btn btn-danger">danger</button>                 </div>                  <div class="input-group">                     <input type="text" class="form-control" aria-label="...">                         <div class="input-group-btn">                         <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">action <span class="caret"></span></button>                     </div><!-- /btn-group -->                 </div><!-- /input-group -->             </form>         </div><!-- /.col-lg-12 -->     </div><!-- /.row --> 

ideal case: button group , input group share same line in #2 , close in #4. in case screen re-sized, expect input stretch first, before line gets broken divs thrown next line.

but how can achieve that? using wrong forms / layout? or css have modified create new kind of layout?

html (case-4)

<div class="row">     <div class="col-lg-12">         <form class="form-inline" role="form">             <div class="btn-group" role="group" aria-label="...">                 <button type="button" class="btn btn-default">default</button>                 <button type="button" class="btn btn-primary">primary</button>                 <button type="button" class="btn btn-success">success</button>                 <button type="button" class="btn btn-info">info</button>                 <button type="button" class="btn btn-warning">warning</button>                 <button type="button" class="btn btn-danger">danger</button>             </div>              <div class="input-group">                 <input type="text" class="form-control" aria-label="...">                     <div class="input-group-btn">                     <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">action <span class="caret"></span></button>                 </div><!-- /btn-group -->             </div><!-- /input-group -->         </form>     </div><!-- /.col-lg-12 --> </div><!-- /.row --> 

with bootstrap 3.0.2

additional css

.btn-group {         display: inline !important; } 

fiddle example

with bootstrap 3.3.5

.btn-group {         display: inline !important; } .form-inline .input-group {     display: flex; } .form-inline .input-group .input-group-btn {     display: flex; } 

fiddle example


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -