Bootstrap内联多个输入

时间:2015-01-12 02:12:40

标签: html css twitter-bootstrap twitter-bootstrap-3

我很难在表单中的一行中放置两个和一个文本输入。我可以让两个选择内联,但文本输入是固执的。以下是当前代码的外观:

enter image description here

<form role='form' action='#' method='post'>
    <div class='form-group'>
        <label for='query-bar' class='sr-only'></label>
        <input type='text' class='form-control' placeholder='Enter search query..' name='query-bar' />
    </div>
    <div class='form-inline'>
        <div class='form-group'>
            <select name='builder-columns' class='form-control'>
                <option selected disabled value='none'>Columns</option>
                <option></option>
            </select>
        </div>
        <div class='form-group'>
            <select name='builder-operators' class='form-control'>
                <option selected disabled value='none'>Operators</option>
            </select>
        </div>
        <div class='form-group'>
            <label for='builder-filter' class='sr-only'></label>
            <input type='text' placeholder='Filter' name='builder-filter' class='form-control' />
        </div>
    </div>
</form>

1 个答案:

答案 0 :(得分:1)

您可以使用以下内容:

<div class='form-inline row'>
    <div class='form-group col-sm-4'>
        <select name='builder-columns' class='form-control'>
            <option selected disabled value='none'>Columns</option>
        </select>
    </div>
    <div class='form-group col-sm-4'>
        <select name='builder-operators' class='form-control'>
            <option selected disabled value='none'>Operators</option>
        </select>
    </div>
    <div class='form-group col-sm-4'>
        <label for='builder-filter' class='sr-only'></label>
        <input type='text' placeholder='Filter' name='builder-filter' class='form-control' />
    </div>
</div>
.form-inline .form-control {
    width: 100%;
}

课程row已添加到form-inline元素,而课程col-sm-4已添加到form-group元素中。此外,.form-control元素的宽度设置为100%,以覆盖在特定屏幕尺寸下应用的width: auto

Example Here