Bootstrap如何制作按钮组?以及水平按钮组和垂直按钮组的优先级?
制作按钮组的基本步骤如下:
- 使用
class="btn-group"
的<div>
包裹按钮组。这将把一组按钮组合在一起。
<div class="btn-group" role="group" aria-label="按钮组">
<button type="button" class="btn btn-primary">按钮1</button>
<button type="button" class="btn btn-primary">按钮2</button>
<button type="button" class="btn btn-primary">按钮3</button>
</div>
- 如果想要创建垂直按钮组,可以使用
class="btn-group-vertical"
。
<div class="btn-group-vertical" role="group" aria-label="垂直按钮组">
<button type="button" class="btn btn-primary">按钮1</button>
<button type="button" class="btn btn-primary">按钮2</button>
<button type="button" class="btn btn-primary">按钮3</button>
</div>
需要注意的是,btn-group
的优先级高于btn-group-vertical
的优先级。因此,如果使用了btn- group
的<div>
包裹按钮组,并且同时使用了btn-group-vertical
的<div>
,则以btn- group
的样式为准,按钮组将水平显示。
THE END
暂无评论内容