Edu
Edu

Reputation: 346

How to align input box with a few sr-only labels in bootstrap

I'm trying to format a form page with bootstrap, some of the inputs have visible labels and some others don't. According to bootstrap documentation(Column sizing section) I have to wrap in "row" classes to set the size of inputs, but when i add sr-only class to some labels it doesn't fit. Any suggestions? Here is the fiddle, the TypeId and DV are not aligned

General Information

                <div class="form-group col-xs-6">
                    <label class="control-label" for="fullname">Full name</label>

                    <input id="fullname" name="fullname" type="text"
                           class="form-control input-md"></input>
                </div>

                    <div class="form-group col-xs-2">
                        <label class="control-label  sr-only" for="TypeId">Type Id</label>

                        <select id="TypeId" name="TypeId" class="form-control  input-md ">
                            <option value="CC">CC</option>
                            <option value="NIT">NIT</option>
                            <option value="NUIP">NUIP</option>
                            <option value="CE">CE</option>
                            <option value="PA">PA</option>
                            <option value="TI">TI</option>
                        </select>
                </div>
                <div class="form-group col-xs-3">
                    <label class="control-label" for="id">Id</label>

                    <input id="id" name="id" type="text" class="form-control input-md"></input>
                </div>
                <div class="form-group col-xs-1">
                        <label class="control-label sr-only" for="DV">DV</label>
                        <input id="DV" name="DV" type="text"
                               class="form-control input-md"></input>
                </div>


            </fieldset>

Upvotes: 1

Views: 763

Answers (1)

Turnip
Turnip

Reputation: 36632

A quick (and hacky!) fix is to add another label after your sr-only label that contains only a &nbsp; and no for attribute:

DEMO

<div class="form-group col-xs-2">
    <label class="control-label  sr-only" for="TypeId">Type Id</label>
    <label class="control-label">&nbsp;</label>
    <select id="TypeId" name="TypeId" class="form-control  input-md ">
        <option value="CC">CC</option>
        <option value="NIT">NIT</option>
        <option value="NUIP">NUIP</option>
        <option value="CE">CE</option>
        <option value="PA">PA</option>
        <option value="TI">TI</option>
    </select>
</div>

Upvotes: 2

Related Questions