如何在bootstrap中将输入框与几个仅sr标签对齐

时间:2014-11-19 15:06:44

标签: html css twitter-bootstrap responsive-design

我尝试使用bootstrap格式化表单页面,其中一些输入具有可见标签,而另一些输入则没有。根据{{​​3}}(列大小调整部分),我必须包含" row"用于设置输入大小的类,但是当我将sr-only类添加到某些标签时,它不适合。有什么建议? bootstrap documentation,TypeId和DV未对齐

一般信息                 

                <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>

1 个答案:

答案 0 :(得分:2)

快速(和hacky!)修复是在sr-only标签之后添加另一个标签,该标签仅包含&nbsp;且没有for属性:

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>