I'm struggling to align Bootstrap buttons and input on the same line, with the input stretching horizontally while snugly fitting against the buttons.
Here are my different attempts: https://i.sstatic.net/wuUsr.png
In attempt #1: the button group and input group are in the same column. The input stretches horizontally but ends up on the 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 -->
For attempt #2: the button group and input group are in two equal columns, but there is a gap between them.
<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 -->
Ideal scenario: where the button group and input group share the same line as in attempt #2, and are closely aligned as in attempt #4. If the screen size changes, I would expect the input to stretch first before wrapping any elements to the next line.
How can this be achieved? Is it an issue with forms or layout, or does the CSS need modification for this new layout?