三、Bootstrap样式设计
3、Bootstrap按钮
Bootstrap 按钮
本章将通过实例讲解如何使用 Bootstrap 按钮。任何带有 class .btn 的元素都会继承圆角灰色按钮的默认外观。但是 Bootstrap 提供了一些选项来定义按钮的样式,具体如下表所示:
以下样式可用于<a>, <button>, 或 <input> 元素上:
类 | 描述 | 实例 |
---|---|---|
.btn | 为按钮添加基本样式 | 尝试一下 |
.btn-default | 默认/标准按钮 | 尝试一下 |
.btn-primary | 原始按钮样式(未被操作) | 尝试一下 |
.btn-success | 表示成功的动作 | 尝试一下 |
.btn-info | 该样式可用于要弹出信息的按钮 | 尝试一下 |
.btn-warning | 表示需要谨慎操作的按钮 | 尝试一下 |
.btn-danger | 表示一个危险动作的按钮操作 | 尝试一下 |
.btn-link | 让按钮看起来像个链接 (仍然保留按钮行为) | 尝试一下 |
.btn-lg | 制作一个大按钮 | 尝试一下 |
.btn-sm | 制作一个小按钮 | 尝试一下 |
.btn-xs | 制作一个超小按钮 | 尝试一下 |
.btn-block | 块级按钮(拉伸至父元素100%的宽度) | 尝试一下 |
.active | 按钮被点击 | 尝试一下 |
.disabled | 禁用按钮 | 尝试一下 |
<div class="bs-docs-example">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>按钮外观</th>
<th>样式(class)</th>
</tr>
</thead>
<tbody>
<tr>
<td><button type="button" class="btn">默认</button></td>
<td><code>btn</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-primary">主要</button></td>
<td><code>btn btn-primary</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-info">信息</button></td>
<td><code>btn btn-info</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-success">成功</button></td>
<td><code>btn btn-success</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-warning">警告</button></td>
<td><code>btn btn-warning</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-danger">危险</button></td>
<td><code>btn btn-danger</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-inverse">反向</button></td>
<td><code>btn btn-inverse</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-link">链接</button></td>
<td><code>btn btn-link</code></td>
</tr>
</tbody>
</table>
</div>
<div class="bs-docs-example">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>按钮外观</th>
<th>样式(class)</th>
</tr>
</thead>
<tbody>
<tr>
<td><button class="btn btn-mini" type="button">Mini button</button></td>
<td><code>btn btn-mini</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-small">Small button</button></td>
<td><code>btn btn-small</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-primary">Default button</button></td>
<td><code>btn btn-primary</code></td>
</tr>
<tr>
<td><button type="button" class="btn btn-large">Large button</button></td>
<td><code>btn btn-large</code></td>
</tr>
</tbody>
</table>
</div>
<div class="container">
<section id="global">
<div class="page-header">
<h3>基本CSS样式 - 特殊样式按钮</h3>
</div>
</section>
<div class="bs-docs-example">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>按钮外观</th>
<th>样式(class)</th>
</tr>
</thead>
<tbody>
<tr>
<td><button type="button" class="btn btn-block">Block level button</button></td>
<td><code>btn btn-block</code></td>
</tr>
<tr>
<td><button type="button" class="btn disabled">disabled button</button></td>
<td><code>btn disabled</code></td>
</tr>
</tbody>
</table>
</div>
</div>
4、Bootstrap图片
Bootstrap框架定义了三种图片样式,分别为.img-rounded类、.img-circle类和.img-polaroid类。
<div class="container">
<section id="global">
<div class="page-header">
<h3>基本CSS样式 - 图片样式</h3>
</div>
</section>
<div class="bs-docs-example bs-docs-example-images">
<img data-src="../assets/js/holder/holder.js/90x90" class="img-rounded">
<img data-src="../assets/js/holder/holder.js/90x90" class="img-circle">
<img data-src="../assets/js/holder/holder.js/90x90" class="img-polaroid">
</div>
</div>