Bootstrap 3 label和select 在同一个DIV中水平显示
时间: 2024-02-11 15:06:11 浏览: 114
要在同一个`div`中水平显示Bootstrap 3的`label`和`select`元素,您可以使用Bootstrap提供的`form-inline`类来实现。以下是一个示例代码:
```html
<div class="form-inline">
<label for="exampleSelect">Select:</label>
<select class="form-control" id="exampleSelect">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
</div>
```
在上面的示例中,我们使用了`form-inline`类来使`label`和`select`元素在同一行中水平显示。同时,我们没有使用Bootstrap的Grid System,而是直接将它们放在同一个`div`中,且没有使用`col-*`类来控制它们的宽度。请注意,`form-inline`类会将所有表单元素都变为行内元素,因此需要谨慎使用。
相关问题
Bootstrap 3 lable select 水平对齐
要使Bootstrap 3的label和select元素水平对齐,您可以使用Bootstrap提供的`form-horizontal`类来实现。以下是一个示例代码:
```html
<form class="form-horizontal">
<div class="form-group">
<label for="exampleSelect" class="col-sm-2 control-label">Select:</label>
<div class="col-sm-4">
<select class="form-control" id="exampleSelect">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
</div>
</div>
</form>
```
在上面的示例中,我们使用了`form-horizontal`类来使表单元素水平对齐。同时,我们使用了Bootstrap的Grid System来将label和select元素放在同一行中,并使用`col-sm-2`和`col-sm-4`类将它们放在不同的列中。最后,我们使用`control-label`类来使label元素垂直居中。
Bootstrap 3 lable select 平行
您可以使用Bootstrap 3的Grid System来水平排列label和select元素。以下是一个示例代码:
```html
<div class="row">
<div class="col-md-2">
<label for="exampleSelect">Select:</label>
</div>
<div class="col-md-4">
<select class="form-control" id="exampleSelect">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
</div>
</div>
```
在上面的示例中,我们使用col-md-2和col-md-4类将label和select元素放在同一行中,且占据不同的列宽。您可以根据需要调整这些列宽。
阅读全文
相关推荐
















