How to align read-only labels and fields in a Bootstrap 2 form

In bootstrap 2, what is the recommended way to line up labels and text fields in a read-only form. The following code example creates inconsistent fields:

<form class="form-horizontal"> <fieldset> <legend>Sample</legend> <div class="control-group"> <label class="control-label">Readonly Field</label> <div class="controls"> Lorem Ipsum and then some </div> </div> </fieldset> </form> 

Please note that I can fix this myself using special CSS. It's not a problem. It just seems silly to me that this is not built in, so I feel that I have to ignore something.

+47
twitter-bootstrap twitter-bootstrap-2
Mar 27 '12 at 10:08
source share
2 answers

You can use uneditable input

 <span class="input-xlarge uneditable-input">Lorem Ipsum and then some</span> 

EDIT:

Starting with bootstrap 3.0, a class has been added to handle this.

If you need to place regular static text next to the form label in a horizontal form, use the .form-control-static class on <p>

 <div class="controls"> <p class="form-control-static">Lorem Ipsum and then some</p> </div> 
+85
Mar 27 '12 at 17:51
source share

There is a hack. You can use <label> with the "checkbox" field

In your case:

 <div class = "controls">
  <label class = "checkbox">
      Lorem ipsum and then some
  </label>
 </div>
+2
Jul 05 '13 at 10:12
source share



All Articles