手册
目录
Bootstrap 5 允许您在按钮组中将一系列按钮组合在一起(在一行上):
请使用带有 .btn-group 类的 <div> 元素来创建按钮组:
<div class="btn-group"> <button type="button" class="btn btn-primary">华为</button> <button type="button" class="btn btn-primary">大疆</button> <button type="button" class="btn btn-primary">小米</button> </div>
提示:请不要将按钮大小应用于组中的每个按钮,而是将类 .btn-group-lg 用于大按钮组或将 .btn-group-sm 用于小按钮组:
<div class="btn-group btn-group-lg"> <button type="button" class="btn btn-primary">华为</button> <button type="button" class="btn btn-primary">大疆</button> <button type="button" class="btn btn-primary">小米</button> </div>
Bootstrap 5 还支持垂直按钮组:
请使用类 .btn-group-vertical 创建垂直按钮组:
<div class="btn-group-vertical"> <button type="button" class="btn btn-primary">华为</button> <button type="button" class="btn btn-primary">大疆</button> <button type="button" class="btn btn-primary">小米</button> </div>
默认情况下,按钮组是 "inline" 的,存在多个按钮组时会并排显示:
<div class="btn-group"> <button type="button" class="btn btn-primary">华为</button> <button type="button" class="btn btn-primary">大疆</button> <button type="button" class="btn btn-primary">小米</button> </div> <div class="btn-group"> <button type="button" class="btn btn-primary">吉利</button> <button type="button" class="btn btn-primary">长城</button> <button type="button" class="btn btn-primary">红旗</button> </div>
嵌套按钮组,可创建下拉菜单(您将在后面的章节中学习有关下拉菜单的更多内容):
<div class="btn-group">
<button type="button" class="btn btn-primary">华为</button>
<button type="button" class="btn btn-primary">大疆</button>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">小米</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">手机</a>
<a class="dropdown-item" href="#">平板电脑</a>
</div>
</div>
</div>
相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.3万人学习
共49课时
77.4万人学习
共29课时
62万人学习
共25课时
39.5万人学习
共43课时
71.3万人学习
共25课时
61.9万人学习
共22课时
23.1万人学习
共28课时
34.1万人学习
共89课时
125.8万人学习