VSP
VSP

Reputation: 2393

twitter bootstrap ajust label field properly in horizontal form

We have the following form:

    <div class="form-horizontal">
   <fieldset>
      <legend>Reports</legend>
      <div class="control-group">
         <label class="control-label">Year</label>
         <div class="controls">
            <select id="ddlYear" class="input-small">
               <option value="2011">2011</option>
               <option selected="selected" value="2012">2012</option>
            </select>
         </div>
      </div>
      <div class="control-group">
         <label class="control-label">Project</label>
         <div class="controls">
            <label class="" id="lbProjectDesc">House X repairs</label>
         </div>
      </div>
      <div class="control-group">
         <label class="control-label">Costs</label>
         <div class="controls">
            <div class="input-append">
               <input type="text" value="0,0" class="span2" id="tbCosts" disabled="disabled"  >
               <span class="add-on">€</span>
            </div>
         </div>
      </div>
      <hr>
      <div class="control-group">
         <div class="controls">
            <input type="submit"  value="Save" onclick="$(this).button('loading');" id="btnSave" class="btn btn-primary" data-loading-text="Saving...">
         </div>
      </div>
   </fieldset>
</div>​

http://jsfiddle.net/9JNcJ/2/

The problem is that the label lbProjectDesc (text= "House X repairs") is not displayed correctly.

What class can we set or what change needs to be made to fix it? (Preferrably the correct way, not a css hack)

Upvotes: 0

Views: 2633

Answers (3)

Selvamani
Selvamani

Reputation: 7684

Avoid the unwanted padding from that and set what ever you want. Here problem is padding.

 #lbProjectDesc {
 margin-top: 5px;
}

add and see.

Demo : http://jsfiddle.net/9JNcJ/5/

Upvotes: 0

VSP
VSP

Reputation: 2393

Taking into account Selva and davidkonrad responses we solved it like this:

.form-horizontal .control-group .controls label {
 margin-top: 5px;
}

This way it affects all the cases where labels are inside horizontal forms but doesnt displace verticaly the description labels of other input types...

Works too with padding-top: 5px;

Upvotes: 1

davidkonrad
davidkonrad

Reputation: 85538

#lbProjectDesc {
margin-top: 5px;
}

(doesn't consider this as a "hack" :) forked : http://jsfiddle.net/davidkonrad/LK95Q/

Upvotes: 1

Related Questions