Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Bootstrap 4 徽章


示例标题

示例标题

示例标题

示例标题

示例标题
示例标题

徽章用于向任何内容添加附加信息。使用 .badge 类以及上下文类(如 .badge-secondary)在 <span> 元素中创建矩形徽章。请注意,徽章会根据父元素(如果有)的大小进行缩放。

示例

<h1>示例标题 <span class="badge badge-secondary">新</span></h1>
<h2>示例标题 <span class="badge badge-secondary">新</span></h2>
<h3>示例标题 <span class="badge badge-secondary">新</span></h3>
<h4>示例标题 <span class="badge badge-secondary">新</span></h4>
<h5>示例标题 <span class="badge badge-secondary">新</span></h5>
<h6>示例标题 <span class="badge badge-secondary">新</span></h6>
尝试一下 »

上下文徽章

主要 次要 成功 危险 警告 信息 浅色 深色

使用任何上下文类 (.badge-*) 来更改徽章的颜色

示例

<span class="badge badge-primary">主要</span>
<span class="badge badge-secondary">次要</span>
<span class="badge badge-success">成功</span>
<span class="badge badge-danger">危险</span>
<span class="badge badge-warning">警告</span>
<span class="badge badge-info">信息</span>
<span class="badge badge-light">浅色</span>
<span class="badge badge-dark">深色</span>
尝试一下 »


药丸徽章

主要 次要 成功 危险 警告 信息 浅色 深色

使用 .badge-pill 类使徽章更圆

示例

<span class="badge badge-pill badge-primary">主要</span>
<span class="badge badge-pill badge-secondary">次要</span>
<span class="badge badge-pill badge-success">成功</span>
<span class="badge badge-pill badge-danger">危险</span>
<span class="badge badge-pill badge-warning">警告</span>
<span class="badge badge-pill badge-info">信息</span>
<span class="badge badge-pill badge-light">浅色</span>
<span class="badge badge-pill badge-dark">深色</span>
尝试一下 »

徽章在元素内部

在按钮中使用徽章的示例

示例

<button type="button" class="btn btn-primary">
  消息 <span class="badge badge-light">4</span>
</button>
尝试一下 »

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.