twitter bootstrap - Need to align a button next to text box in form-group -


form-group

i new bootstrap.

as seen in picture trying use form-group , form structure given button doesn't seem align textbox. please current code

<div class="form-group">         <span for="artistname" class="control-label">enter artist name</span></br>         <input id="artistname" type="text" ng-modal="artist1" class="form-control text_element_width" placeholder="enter artist name." />         <button type="button" class="btn btn-default glyphicon glyphicon-plus" ng-click="addartistchoice()">add artist</button>     </div>     <div data-ng-repeat="artist in artists" class="form-group">         <input type="text" ng-modal="{{artist.artistname}}" class="form-control text_element_width" placeholder="enter artist name.">         <a href=""><span class="glyphicon glyphicon-trash" ng-click="removeartistchoice(artist)" /></a>     </div> 

you have couple of options here. first 1 combine .form-horizontal .form-group , bootstrap grid system. results in fully-defined button adjacent input field.

but bootstrap has component .input-group allows affix button directly input; that's option too! examples of both follow:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>  <div class="form-horizontal">  	<label for="artistname" class="control-label">enter artist name</label>  	<div class="form-group">  		<div class="col-xs-9">  			<input id="artistname" type="text" ng-modal="artist1" class="form-control text_element_width" placeholder="enter artist name." />  		</div>  	  		<div class="col-xs-3">  			<button type="button" class="btn btn-default btn-block" ng-click="addartistchoice()"><span class="glyphicon glyphicon-plus"></span> add artist</button>  		</div>  	</div>  </div>    <hr />    <label for="artistname" class="control-label">enter artist name</label>  <div class="input-group">  	<input id="artistname" type="text" ng-modal="artist1" class="form-control text_element_width" placeholder="enter artist name." />  	<div class="input-group-btn">  			<button type="button" class="btn btn-default" ng-click="addartistchoice()"><span class="glyphicon glyphicon-plus"></span> add artist</button>  	</div>  </div>

please note in addition 2 examples, made changes how you're calling glyph icon.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -