按钮组 - Button Groups

水平按钮组

将按钮包含在 .btn-group 样式的容器内,即可创建按钮组

<div class="btn-group">
    <button type="button" class="btn btn-primary">Left</button>
    <button type="button" class="btn btn-primary">Middle</button>
    <button type="button" class="btn btn-primary">Right</button>
</div>
01.PNG

垂直按钮组

按钮组也可以垂直排列

<div class="btn-group-vertical">
    <button type="button" class="btn btn-primary">Top</button>
    <button type="button" class="btn btn-primary">Middle</button>
    <button type="button" class="btn btn-primary">Bottom</button>
</div>
02.PNG

按钮组工具条

将按钮组包裹在 .btn-toolbar 样式的容器中就形成了按钮组工具条

<div class="btn-toolbar">
    <div class="btn-group">
        <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>
        <button type="button" class="btn btn-primary">4</button>
    </div>
    <div class="btn-group">
        <button type="button" class="btn btn-primary">5</button>
        <button type="button" class="btn btn-primary">6</button>
        <button type="button" class="btn btn-primary">7</button>
    </div>
    <div class="btn-group">
        <button type="button" class="btn btn-primary">8</button>
    </div>
</div>
03.PNG

不同尺寸的按钮组

为按钮组设置 .btn-group-sm 之类的样式

<div class="btn-toolbar">
    <div class="btn-group btn-group-lg">
        <button type="button" class="btn btn-primary">Left</button>
        <button type="button" class="btn btn-primary">Middle</button>
        <button type="button" class="btn btn-primary">Right</button>
    </div>
</div>
<br>
<div class="btn-toolbar">
    <div class="btn-group">
        <button type="button" class="btn btn-primary">Left</button>
        <button type="button" class="btn btn-primary">Middle</button>
        <button type="button" class="btn btn-primary">Right</button>
    </div>
</div>
<br>
<div class="btn-toolbar">
    <div class="btn-group btn-group-sm">
        <button type="button" class="btn btn-primary">Left</button>
        <button type="button" class="btn btn-primary">Middle</button>
        <button type="button" class="btn btn-primary">Right</button>
    </div>
</div>
<br>
<div class="btn-toolbar">
    <div class="btn-group btn-group-xs">
        <button type="button" class="btn btn-primary">Left</button>
        <button type="button" class="btn btn-primary">Middle</button>
        <button type="button" class="btn btn-primary">Right</button>
    </div>
</div>
04.PNG

两端对齐按钮组

如果用 <a> 元素创建按钮,则可以把所有按钮直接包含在按钮组中;
如果用 <button> 元素创建按钮,则每个按钮都要包含在按钮组中;

<div class="bs-example">
    <div class="btn-group btn-group-justified">
        <a href="#" class="btn btn-primary">Left</a>
        <a href="#" class="btn btn-primary">Middle</a>
        <a href="#" class="btn btn-primary">Right</a>
    </div>
</div>


<div class="bs-example">
    <div class="btn-group btn-group-justified">
        <div class="btn-group">
            <button type="button" class="btn btn-primary">Left</button>
        </div>
        <div class="btn-group">
            <button type="button" class="btn btn-primary">Middle</button>
        </div>
        <div class="btn-group">
            <button type="button" class="btn btn-primary">Right</button>
        </div>
    </div>
</div>
05.PNG
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 第5章 菜单、按钮及导航 一、下拉菜单 小伙伴们注意,在Bootstrap框架中的下拉菜单组件是一个独立的组件,根...
    凛0_0阅读 5,043评论 0 66
  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 13,790评论 1 92
  • CSS全局样式 概览 移动设备优先 布局容器 1、container类用于固定宽度并支持响应式布局的容器 2、co...
    VEN_64d6阅读 1,421评论 0 1
  • 我们铸起条条高架桥 让它们像缎带一样在空中缠绕 我们拓展道路 宽得像飞机的跑道 我们在地下像土拔鼠一样挖洞 这一切...
    风雨菩提阅读 457评论 2 6
  • 1、首先蓝可儿是个女生,还是个漂亮的女生,单独行走已经引起色魔注意和跟踪. 2、出于防备心理,她进了电梯就按下了各...
    青灯禅阅读 8,118评论 0 1