Bootstrap的“spinners”可用于显示项目中的加载状态。它们只使用HTML和CSS构建,这意味着您不需要任何JavaScript来创建它们。但是,您需要一些自定义JavaScript来切换它们的可见性。它们的外观、对齐和大小可以通过我们令人惊叹的实用程序类轻松定制。
为了便于访问,这里的每个加载程序都包括 role=“status"
和嵌套的 <span class="sr-only">Loading...</span>
。
<div class="spinner-border" role="status"> <span class="sr-only">Loading...</span> </div>
<div class="spinner-border text-primary" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-border text-secondary" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-border text-success" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-border text-danger" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-border text-warning" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-border text-info" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-border text-light" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-border text-dark" role="status"> <span class="sr-only">Loading...</span> </div>
border-color
工具?每个边框微调器至少为一侧指定一个透明边框,因此 .border-{color}
实用程序将覆盖该边框。<div class="spinner-grow" role="status"> <span class="sr-only">Loading...</span> </div>
<div class="spinner-grow text-primary" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-grow text-secondary" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-grow text-success" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-grow text-danger" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-grow text-warning" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-grow text-info" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-grow text-light" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-grow text-dark" role="status"> <span class="sr-only">Loading...</span> </div>
<div class="spinner-border m-5" role="status"> <span class="sr-only">Loading...</span> </div>
<div class="d-flex justify-content-center"> <div class="spinner-border" role="status"> <span class="sr-only">Loading...</span> </div> </div>
<div class="d-flex align-items-center"> <strong>Loading...</strong> <div class="spinner-border ml-auto" role="status" aria-hidden="true"></div> </div>
<div class="clearfix"> <div class="spinner-border float-right" role="status"> <span class="sr-only">Loading...</span> </div> </div>
<div class="text-center"> <div class="spinner-border" role="status"> <span class="sr-only">Loading...</span> </div> </div>
<div class="spinner-border spinner-border-sm" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-grow spinner-grow-sm" role="status"> <span class="sr-only">Loading...</span> </div>
或者,使用自定义CSS或内联样式根据需要更改维度。
<div class="spinner-border" style="width: 3rem; height: 3rem;" role="status"> <span class="sr-only">Loading...</span> </div> <div class="spinner-grow" style="width: 3rem; height: 3rem;" role="status"> <span class="sr-only">Loading...</span> </div>
<button class="btn btn-primary" type="button" disabled> <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="sr-only">Loading...</span> </button> <button class="btn btn-primary" type="button" disabled> <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading... </button>
<button class="btn btn-primary" type="button" disabled> <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span> <span class="sr-only">Loading...</span> </button> <button class="btn btn-primary" type="button" disabled> <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span> Loading... </button>