在Bootstrap中,您可以使用内置的spinner组件来表示加载或处理状态
<head>
部分中包含以下链接:<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- JavaScript --><script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js"></script>
<div class="spinner-border" role="status">
<span class="visually-hidden">Loading...</span>
</div>
这将显示一个默认大小且具有边框样式的spinner。
.spinner-border-sm
类来获得一个较小的spinner,或者在.spinner-border
之后添加.spinner-border-lg
类来获得一个较大的spinner。例如:
<!-- Small spinner -->
<div class="spinner-border spinner-border-sm" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<!-- Large spinner -->
<div class="spinner-border spinner-border-lg" role="status">
<span class="visually-hidden">Loading...</span>
</div>
.spinner-border
元素添加text-{color}
类,其中{color}
是Bootstrap支持的颜色名称(如primary
、secondary
、success
等)。例如:
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
.spinner-grow
类与.spinner-grow-sm
或.spinner-grow-lg
类结合使用。例如:
<!-- Small growing spinner -->
<div class="spinner-grow spinner-grow-sm text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<!-- Large growing spinner -->
<div class="spinner-grow spinner-grow-lg text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
现在,您应该已经成功地在Bootstrap项目中实现了spinner组件。根据需要自定义颜色、大小和类型,以适应您的设计。