I’m trying to display a text input inline with a dropdown button. I can’t figure out how to do this though. Here’s the HTML I’ve tried (I’ve put all of it on a single line with no results):
<div class="input-append">
<input type="text" placeholder="foo" class="input-mini">
<div class="btn-group">
<a id="amount_type" class="btn dropdown-toggle" data-toggle="dropdown" href="#">10<span class="caret"></span></a>
<ul id="amount_type_options" class="dropdown-menu">
<li class="selected"><a href="#">10</a></li>
<li><a href="#">100</a></li>
<li><a href="#">1000</a></li>
</ul>
</div>
</div>
Is this possible?
Thank you
Current state: default implementation in docs
Currently there is a default implementation of input+dropdown combo in the documentation here (search for “Button dropdowns”). I leave the original solution for the record and for those who cannot use solution now included in the documentation.
Original solution
Yes, it is possible. As a matter of fact, there is one example in the Twitter Bootstrap documentation (follow the link and search “Examples” for dropdown buttons):
If enclosed within text, it can look like this (with text on the button changed, nothing else):
EDIT:
If you are trying to achieve
<input>with appended dropdown menu as in the dropdown buttons, then this is one of the solutions:btn-groupclass to the element that hasinput-appendclass,dropdown-toggleanddropdown-menuat the end of the element with classinput-append,.input-append .btn.dropdown-menuso it does not havefloat: left(otherwise it will get into next line).The resulting code may look like this:
with a little support from this style override:
and give you the exact same result as this:
EDIT 2: Updated the CSS selector (was
.dropdown-menu, is.dropdown-toggle).