Bootstrap 4 徽章(Badges)
示例标题 New
示例标题 New
示例标题 New
示例标题 New
示例标题 New
示例标题 New
徽章(Badges)主要用于突出显示新的或未读的项。如需使用徽章,只需要将 .badge
类加上带有指定意义的颜色类 (如 .badge-secondary
) 添加到 <span>
元素上即可。 徽章可以根据父元素的大小的变化而变化:
实例
<h1>示例标题 <span class="badge badge-secondary">New</span></h1>
<h2>示例标题 <span class="badge badge-secondary">New</span></h2>
<h3>示例标题 <span class="badge badge-secondary">New</span></h3>
<h4>示例标题 <span class="badge badge-secondary">New</span></h4>
<h5>示例标题 <span class="badge badge-secondary">New</span></h5>
<h6>示例标题 <span class="badge badge-secondary">New</span></h6>
亲自试一试 »各种颜色类型的徽章
主要
次要
成功
危险
警告
信息
浅色
深色
可以使用任何上下文类 (.badge-*
) 更改徽章的颜色:
实例
<span class="badge badge-primary">Primary</span>
<span class="badge
badge-secondary">Secondary</span>
<span class="badge
badge-success">Success</span>
<span class="badge
badge-danger">Danger</span>
<span class="badge
badge-warning">Warning</span>
<span class="badge badge-info">Info</span>
<span class="badge badge-light">Light</span>
<span class="badge
badge-dark">Dark</span>
亲自试一试 »模态形状徽章
主要
次要
成功
危险
警告
信息
浅色
暗色
使用 .badge-pill
类来设置模态形状徽章:
实例
<span class="badge badge-pill badge-primary">Primary</span>
<span
class="badge badge-pill badge-secondary">Secondary</span>
<span
class="badge badge-pill badge-success">Success</span>
<span class="badge
badge-pill badge-danger">Danger</span>
<span class="badge badge-pill
badge-warning">Warning</span>
<span class="badge badge-pill
badge-info">Info</span>
<span class="badge badge-pill
badge-light">Light</span>
<span class="badge badge-pill
badge-dark">Dark</span>
亲自试一试 »徽章插入到元素内
以下实例将徽章嵌入到按钮内:
实例
<button type="button" class="btn btn-primary">
Messages <span class="badge badge-light">4</span>
</button>
亲自试一试 »