I am trying to create a form with form elements side by side and their labels (aligned with the beginning of the corresponding input element) on top of them:
Label Label2 +----------------+ +-------+ +----------------+ +-------+
The following does not work as expected, because "Label2" does not align slightly with the input element:
<div class="controls controls-row"> <label class="span9"><span>Label</span></label> <label class="span2"><span>Label2</span></label> </div> <div class="controls controls-row"> <input type="text" class="span9" /> <input type="text" class="span2" /> </div>
I got it to work using this workaround:
<div class="controls controls-row"> <div class="span9"> <label><span>Label</span></label> </div> <div class="span2"> <label><span>Label2</span></label> </div> </div> <div class="controls controls-row"> <div class="span9"> <input type="text" class="span12" /> </div> <div class="span2"> <input type="text" class="span12" /> </div> </div>
So could this be a mistake? Since the Bootstrap Twitter page says:
Use .span1 for .span12 for inputs that correspond to the same grid column sizes.
Here's a JSFiddle that reproduces my problem.
source share