I'm trying to get the buttons on these form controls:
Bootply Example
to look like the controls in this example:
Bootsnipp Example
Basically I am trying to re-create the Bootsnipp example using Bootstrap3 [Bootstrap 3.1.1] form controls.
Here is the HTML:
<div class="container">
<div class="row">
<div class="controls">
<div class="entry form-group col-sm-4">
<div class="input-group">
<input class="form-control" name="fields[]" type="text" placeholder="Type something">
<button class="btn btn-success btn-add" type="button"><span class="glyphicon glyphicon-plus"></span></button>
</div>
</div>
<div class="entry form-group col-sm-4">
<div class="input-group">
<input class="form-control" name="fields[]" type="text" placeholder="Type something">
<button class="btn btn-success btn-add" type="button"><span class="glyphicon glyphicon-plus"></span></button>
</div>
</div>
<div class="entry form-group col-sm-4">
<div class="input-group">
<input class="form-control" name="fields[]" type="text" placeholder="Type something">
<button class="btn btn-success btn-add" type="button"><span class="glyphicon glyphicon-plus"></span></button>
</div>
</div>
</div>
</div>
</div>
UPDATE
Would up using a bootstrap form generator that gave me this:
<div class="tag-controls">
<div class="entry col-sm-4 form-group ">
<div class="input-group">
<input class="form-control" name="tags[]" type="text" placeholder="Type something" />
<div class="input-group-btn">
<button class="btn btn-success btn-add" type="button" data-target="tag-controls"><span class="glyphicon glyphicon-plus"></span></button>
</div>
</div>
</div>
</div>
Similar to Shawn's answer, which I didn't try I found most of these solutions broke when trying to apply the column sizing to a parent element.
Use the . btn-link class in Bootstrap to create a button look like a link.
Use the . btn-group class in Bootstrap to group buttons on a single like.
You can use an out div with a class btn-group . This helps to align the buttons horizontally. Using col-md-6 for each button div can make the buttons missaligned with unwanted space in between.
Instead of applying button sizing classes to every button in a group, just add . btn-group-* to each . btn-group , including each one when nesting multiple groups.
You need to wrap the button in a span with class .input-group-btn
like so:
<input class="form-control" name="fields[]" type="text" placeholder="Type something">
<span class="input-group-btn"><!-- DO THIS -->
<button class="btn btn-success btn-add" type="button">
<span class="glyphicon glyphicon-plus"></span>
</button>
</span>
DEMO: http://www.bootply.com/BNUUlFK5xX
You were missing classes and wrappers and had others that I am not familiar with with 3.x
http://www.bootply.com/V5fU59ukqE
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="input-group">
<input class="form-control" name="fields[]" placeholder="Type something" type="text">
<span class="input-group-btn">
<button class="btn btn-success" type="button"><span class="glyphicon glyphicon-plus"></span></button>
</span>
</div>
</div>
<div class="col-sm-4">
<div class="input-group">
<input class="form-control" name="fields[]" placeholder="Type something" type="text">
<span class="input-group-btn">
<button class="btn btn-success" type="button"><span class="glyphicon glyphicon-plus"></span></button>
</span>
</div>
</div>
<div class="col-sm-4">
<div class="input-group">
<input class="form-control" name="fields[]" placeholder="Type something" type="text">
<span class="input-group-btn">
<button class="btn btn-success" type="button"><span class="glyphicon glyphicon-plus"></span></button>
</span>
</div>
</div>
</div>
</div>
For Vertical spacing when it collapses, you need yet another wrapper (Bootstrap forms are wrapper heavy) just inside the column "form-group":
<div class="col-sm-4">
<div class="form-group">
<div class="input-group">
<input class="form-control" name="fields[]" placeholder="Type something" type="text">
<span class="input-group-btn">
<button class="btn btn-success" type="button"><span class="glyphicon glyphicon-plus"></span></button>
</span>
</div>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With