Label on the left side instead above an input field

113

I would like to have the labels not above the input field, but on the left side.

<form method="post" action="" role="form" class="form-inline">
  <div class="form-group">
    <label for="rg-from">Ab: </label>
    <input type="text" id="rg-from" name="rg-from" value="" class="form-control">
  </div>
  <div class="form-group">
    <label for="rg-to">Bis: </label>
    <input type="text" id="rg-to" name="rg-to" value="" class="form-control">
  </div>
  <div class="form-group">
    <input type="button" value="Clear" class="btn btn-default btn-clear"> 
    <input type="submit" value="Los!" class="btn btn-primary">
  </div>
</form>

This code gives me:

Code_Result_Bootstrap_3_Label

I would like to have:

Desired_Result_Bootstrap_3_Label

This question is tagged with css twitter-bootstrap-3

~ Asked on 2013-08-23 13:24:47

The Best Answer is


98

You can use form-inline class for each form-group :)

<form>                      
    <div class="form-group form-inline">                            
        <label for="exampleInputEmail1">Email address</label>
            <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
    </div>
</form>

~ Answered on 2015-11-28 18:20:22


56

Put the <label> outside the form-group:

<form class="form-inline">
  <label for="rg-from">Ab: </label>
  <div class="form-group">
    <input type="text" id="rg-from" name="rg-from" value="" class="form-control">
  </div>
  <!-- rest of form -->
</form>

~ Answered on 2014-02-11 20:47:18


Most Viewed Questions: