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 徽章和标签


徽章

徽章是与链接关联的项目数量的数字指示器

新闻 5
评论 10
更新 2

数字 (5、10 和 2) 是徽章。

<span> 元素中使用 .badge 类来创建徽章

示例

<a href="#">新闻 <span class="badge">5</span></a><br>
<a href="#">评论 <span class="badge">10</span></a><br>
<a href="#">更新 <span class="badge">2</span></a>
试一试 »

徽章也可以用在其他元素中,例如按钮



以下示例展示了如何在按钮中添加徽章

示例

<button type="button" class="btn btn-primary">主要 <span class="badge">7</span></button>
试一试 »


标签

标签用于提供有关事物的更多信息

示例 新建

示例 新建

示例 新建

示例 新建

示例 新建
示例 新建

使用 .label 类,后跟六个上下文类之一 .label-default.label-primary.label-success.label-info.label-warning.label-danger,在 <span> 元素中创建一个标签

示例

<h1>示例 <span class="label label-default">新建</span></h1>
<h2>示例 <span class="label label-default">新建</span></h2>
<h3>示例 <span class="label label-default">新建</span></h3>
<h4>示例 <span class="label label-default">新建</span></h4>
<h5>示例 <span class="label label-default">新建</span></h5>
<h6>示例 <span class="label label-default">新建</span></h6>
试一试 »

以下示例展示了所有上下文标签类

默认标签 主要标签 成功标签 信息标签 警告标签 危险标签

示例

<span class="label label-default">默认标签</span>
<span class="label label-primary">主要标签</span>
<span class="label label-success">成功标签</span>
<span class="label label-info">信息标签</span>
<span class="label label-warning">警告标签</span>
<span class="label label-danger">危险标签</span>
试一试 »

通过练习测试自己

练习

在 "评论" 文本之后,使用 span 元素在其中创建一个带有数字 2 的徽章。

<button>Comments </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.