bootstrap表单输入字段对齐

时间:2013-01-25 16:36:05

标签: twitter-bootstrap

我有以下代码

<form id="editProfileForm" class="form-horizontal span8"  method="post">  
    <div class="control-group">
        <label class="control-label" for="inputSubject">Subject</label>
        <div class="controls">
            <input type="text" id="inputSubject" class="span8" >
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="inputTags">Tags</label>
        <div class="controls">                            
            <input type="text" id="inputTags" class="span3">  
        </div>        
    </div> 

    <div class="control-group">
        <label class="control-label" for="inputAccess">access</label>
        <div class="controls">                            
            <input type="text" id="inputAccess" class="span3">  
        </div>        
    </div>

我收到的信息如下enter image description here

有人可以建议我如何在下面这样做吗?谢谢你的帮助

enter image description here

JS小提琴链接http://jsfiddle.net/kLuB3/331/

1 个答案:

答案 0 :(得分:5)

form-inlineform-horizontal更适合这种情况。

试试这个:

<form id="editProfileForm" class="span8 form-inline" method="post">
    <div class="row">
        <label class="span1" for="inputSubject">Subject</label>
        <input type="text" id="inputSubject" class="span7">
    </div>
    <div class="row">
        <label class="span1" for="inputTags">Tags</label>
        <input type="text" id="inputTags" class="span3">
        <label class="span1" for="inputAccess" id="inputAccessLabel">access</label>
        <input type="text"id="inputAccess" class="span3">
    </div>
</form>

使用这个CSS:

#inputTags, #inputAccess {
    float: left !important;
}
#inputAccessLabel {
    margin-left: 35px;
    margin-right: 5px;
}

jsFiddle