<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<title>Bootstrap 4 徽章</title>
</head>
<body>
<div class="container mt-4">
<h2>徽章示例</h2>
<!-- 基本徽章 -->
<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>
<!-- 显示数字的徽章 -->
<span class="badge badge-primary">5</span>
<!-- 徽章放置在链接上 -->
<a href="#" class="badge badge-info">链接徽章</a>
</div>
<!-- Bootstrap JavaScript 和 jQuery(可选)-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</body>
</html>
在这个例子中,我们使用了badge类来创建徽章,并根据需要添加不同的颜色类(如badge-primary、badge-secondary等)。你还可以在徽章中显示数字,如上面的示例所示。徽章可以放置在文本或链接上,用于突出显示某些信息。
转载请注明出处:http://www.zyzy.cn/article/detail/5491/Bootstrap