html - Input group addons altering the total width of an input group -
i've noticed when using control group addons bootstrap total width of control group larger controls not have addons. width change not seem affected number of addons used.
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" /> <div class="container-fluid"> <form role="form" class="form-horizontal"> <div class="form-group"> <label for="inputelementname" class="control-label col-sm-4">element name</label> <div class="col-sm-6"> <input type="text" class="form-control" id="inputelementname" placeholder="enter name element" /> </div> </div> <div class="form-group"> <label for="inputelementfrequency" class="control-label col-sm-4">element frequency</label> <div class="col-sm-6 input-group"> <span class="input-group-addon">every</span> <input type="number" class="form-control" id="inputelementfrequency" placeholder="enter how element appears." /> <span class="input-group-addon">numbers</span> </div> </div> <div class="form-group"> <label for="inputelementdata" class="control-label col-sm-4">element data</label> <div class="col-sm-6 input-group"> <input type="number" class="form-control" id="inputelementdata" placeholder="enter element's data." /> <span class="input-group-addon">data</span> </div> </div> </form> </div>
how can ensure controls fill same width, regardless of addons?
the .input-group
div should part of own element instead of lumped in .col-xs-6
. remember, .input-group
div taking place of input control. use them interchangeably.
instead of this:
<div class="col-sm-6 input-group"> <span class="input-group-addon">every</span> <input type="number" class="form-control" /> </div>
do this:
<div class="col-sm-6 "> <div class="input-group"> <span class="input-group-addon">every</span> <input type="number" class="form-control" /> </div> </div>
demo in stack snippets
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" /> <div class="container-fluid"> <form role="form" class="form-horizontal"> <div class="form-group"> <label for="inputelementname" class="control-label col-sm-4">element name</label> <div class="col-sm-6"> <input type="text" class="form-control" id="inputelementname" placeholder="enter name element" /> </div> </div> <div class="form-group"> <label for="inputelementfrequency" class="control-label col-sm-4">element frequency</label> <div class="col-sm-6 "> <div class="input-group"> <span class="input-group-addon">every</span> <input type="number" class="form-control" id="inputelementfrequency" placeholder="enter how element appears." /> <span class="input-group-addon">numbers</span> </div> </div> </div> <div class="form-group"> <label for="inputelementdata" class="control-label col-sm-4">element data</label> <div class="col-sm-6 "> <div class="input-group"> <input type="number" class="form-control" id="inputelementdata" placeholder="enter element's data." /> <span class="input-group-addon">data</span> </div> </div> </div> </form> </div>
Comments
Post a Comment