徽章(Badges)主要用于突出顯示新的或未讀的項。如需使用徽章,隻需要将 .badge 類加上帶有指定意義的顔色類 (如 .bg-secondary) 添加到 <span>
元素上即可。 徽章可以根據父元素的大小的變化而變化:
<h1>測試标題 <span class="badge bg-secondary">New</span></h1>
<h2>測試标題 <span class="badge bg-secondary">New</span></h2>
<h3>測試标題 <span class="badge bg-secondary">New</span></h3>
<h4>測試标題 <span class="badge bg-secondary">New</span></h4>
<h5>測試标題 <span class="badge bg-secondary">New</span></h5>
<h6>測試标題 <span class="badge bg-secondary">New</span></h6>
以下列出了所有顔色類型的徽章:
<span class="badge bg-primary">主要</span>
<span class="badge bg-secondary">次要</span>
<span class="badge bg-success">成功</span>
<span class="badge bg-danger">危險</span>
<span class="badge bg-warning">警告</span>
<span class="badge bg-info">資訊</span>
<span class="badge bg-light">淺色</span>
<span class="badge bg-dark">深色</span>
使用 .rounded-pill 類來設定藥丸形狀徽章:
<span class="badge rounded-pill bg-default">預設</span>
<span class="badge rounded-pill bg-primary">主要</span>
<span class="badge rounded-pill bg-success">成功</span>
<span class="badge rounded-pill bg-info">資訊</span>
<span class="badge rounded-pill bg-warning">警告</span>
<span class="badge rounded-pill bg-danger">危險</span>
以下執行個體将徽章嵌入到按鈕内:
<button type="button" class="btn btn-primary">
Messages <span class="badge bg-light">4</span>
</button>