设置bootstrap按钮组选中状态
时间: 2023-08-05 15:05:30 浏览: 42
要设置Bootstrap按钮组中的选中状态,可以使用active类。在按钮上添加active类将使其显示为选中状态。
例如,如果您有一个按钮组如下所示:
```html
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-secondary">Left</button>
<button type="button" class="btn btn-secondary">Middle</button>
<button type="button" class="btn btn-secondary">Right</button>
</div>
```
要将中间按钮设置为选中状态,只需将其添加active类,如下所示:
```html
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-secondary">Left</button>
<button type="button" class="btn btn-secondary active">Middle</button>
<button type="button" class="btn btn-secondary">Right</button>
</div>
```
这将使“Middle”按钮显示为选中状态。