In creating forms using Twitter Bootstrap, how do you add help text above the input rather than below it. When I insert a statement above the input using the "help-block" class, the label and the input no longer align. Is there a way around that?
Two: [a \/] and so on... then labels are not on the same line as the form fields. Is the only solution: <div><label for="one">One:</label> <input type="text" id="one"></div> ...
The control-label class is useful for validation states, that's why we need it in all labels even the fields bootstrap's documentation doesn't mention.
The bootstrap already have this kind of resource on it's css class. Take a look on the samples.
Your code must be on a form-group
class, like this:
<div class="form-group">
<label for="info-email" class="col-xs-2 control-label">e-mail</label>
<div class="col-xs-10">
<input type="text" class="form-control" id="info-email" placeholder="Your e-mail">
<small class="text-muted">We'll never share your email with anyone else.</small>
</div>
</div>
And, if you need to put the help text above the input, just change the place of the <small>...</small>
to the above of the input:
<div class="form-group">
<label for="info-email" class="col-xs-2 control-label">e-mail</label>
<div class="col-xs-10">
<small class="text-muted">We'll never share your email with anyone else.</small>
<input type="text" class="form-control" id="info-email" placeholder="Your e-mail">
</div>
</div>
Prepend help-block class element to controls
<div class="control-group">
<label for="prependedInput" class="control-label">Prepended text</label>
<div class="controls">
<p class="help-block">Here's some help text</p>
<div class="input-prepend">
<input type="text" class="span2" id="prependedInput" size="16">
</div>
</div>
Instead of appending
<div class="control-group">
<label for="prependedInput" class="control-label">Prepended text</label>
<div class="controls">
<div class="input-prepend">
<input type="text" class="span2" id="prependedInput" size="16">
</div>
<p class="help-block">Here's some help text</p>
</div>
Demo: http://jsfiddle.net/D2RLR/935/
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