- 引导布局
- Bootstrap - 断点
- Bootstrap - 容器
- Bootstrap - 网格系统
- Bootstrap - 列
- Bootstrap - 排水沟
- Bootstrap - 实用程序
- Bootstrap - Z 索引
- Bootstrap - CSS 网格
- 引导组件
- Bootstrap - 手风琴
- Bootstrap - 警报
- Bootstrap - 徽章
- Bootstrap - 面包屑导航
- Bootstrap - 按钮
- Bootstrap - 按钮组
- Bootstrap - 卡片
- Bootstrap - 轮播
- Bootstrap - 关闭按钮
- Bootstrap - 折叠
- Bootstrap - 下拉菜单
- Bootstrap - 列表组
- Bootstrap - 模态
- Bootstrap - 导航栏
- Bootstrap - 导航和选项卡
- Bootstrap - Offcanvas
- Bootstrap - 分页
- Bootstrap - 占位符
- Bootstrap - 弹出窗口
- Bootstrap - 进展
- Bootstrap-Scrollspy
- Bootstrap - 旋转器
- Bootstrap - 吐司
- Bootstrap - 工具提示
- 引导表单
- Bootstrap - 表单
- Bootstrap - 表单控制
- 引导程序 - 选择
- Bootstrap - 支票和收音机
- Bootstrap - 范围
- Bootstrap - 输入组
- Bootstrap - 浮动标签
- Bootstrap - 布局
- 引导程序 - 验证
- 引导助手
- Bootstrap-Clearfix
- Bootstrap - 颜色和背景
- Bootstrap - 彩色链接
- Bootstrap - 聚焦环
- Bootstrap - 图标链接
- Bootstrap - 位置
- Bootstrap - 比率
- Bootstrap - 堆栈
- Bootstrap - 拉伸链接
- Bootstrap - 文本截断
- Bootstrap - 垂直规则
- Bootstrap - 视觉隐藏
- 引导实用程序
- Bootstrap - 背景
- Bootstrap - 边框
- Bootstrap - 颜色
- Bootstrap - 显示
- Bootstrap-Flex
- Bootstrap - 浮动
- Bootstrap - 交互
- 引导程序 - 链接
- Bootstrap - 对象拟合
- Bootstrap - 不透明度
- Bootstrap - 溢出
- Bootstrap - 位置
- Bootstrap - 阴影
- Bootstrap - 尺寸调整
- Bootstrap - 间距
- Bootstrap - 文本
- Bootstrap - 垂直对齐
- Bootstrap - 可见性
- 引导演示
- Bootstrap - 网格演示
- Bootstrap - 按钮演示
- Bootstrap - 导航演示
- Bootstrap - 博客演示
- Bootstrap - 滑块演示
- Bootstrap - 轮播演示
- Bootstrap - 标头演示
- Bootstrap - 页脚演示
- Bootstrap - 英雄演示
- Bootstrap - 特色演示
- Bootstrap - 侧边栏演示
- Bootstrap - 下拉菜单演示
- Bootstrap - 列表组演示
- Bootstrap - 模态演示
- Bootstrap - 徽章演示
- Bootstrap - 面包屑演示
- Bootstrap - Jumbotrons 演示
- Bootstrap-粘性页脚演示
- Bootstrap-相册演示
- Bootstrap-登录演示
- Bootstrap 定价演示
- Bootstrap-Checkout 演示
- Bootstrap-产品演示
- Bootstrap-封面演示
- Bootstrap-仪表板演示
- Bootstrap-粘性页脚导航栏演示
- Bootstrap-Masonry 演示
- Bootstrap-Starter 模板演示
- Bootstrap-Album RTL 演示
- Bootstrap-Checkout RTL 演示
- Bootstrap-Carousel RTL 演示
- Bootstrap-博客 RTL 演示
- Bootstrap-仪表板 RTL 演示
- Bootstrap 有用资源
- Bootstrap - 问题与解答
- Bootstrap - 快速指南
- Bootstrap - 有用的资源
- Bootstrap - 讨论
Bootstrap - 旋转器
本章将讨论 Bootstrap 微调器。Bootstrap spinner 使用.spinner类显示项目的加载状态。
怎么运行的
Bootstrap 微调器使用 HTML 和 CSS 显示项目的加载状态。构建它们不需要 JavaScript。
需要自定义 JavaScript 来切换其可见性。可以使用 Bootstrap 的实用程序类轻松自定义外观、对齐方式和大小。
- 每个加载器都有role="status"和嵌套的<span class="visually-hidden">正在加载... </span >以实现可访问性。
边框旋转器
使用.spinner-border类创建轻量级微调器/加载指示器。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h3>Border Spinner</h3> <div class="spinner-border mt-2" role="status"> <span class="spinner-grow text-white spinner-grow-sm" role="status"></span> <span class="visually-hidden"></span> </div> </body> </html>
颜色
边框微调器使用currentColor作为其边框颜色,可以使用文本颜色实用程序进行自定义。在标准微调器上使用文本颜色实用程序。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h3>Colored Spinner</h3> <div class="spinner-border text-primary" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-border text-secondary" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-border text-success" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-border text-danger" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-border text-warning" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-border text-info" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-border text-light" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-border text-dark" role="status"> <span class="visually-hidden"></span> </div> </body> </html>
为什么不使用边框颜色实用程序?边框微调器的一侧具有透明边框,由.border-{color}实用程序覆盖。
种植旋转器
您可以将微调器的旋转类型更改为生长微调器。从技术上讲,它不会旋转,但会反复生长。
使用.spinner-grow类创建增长微调器。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h3>Growing Spinner</h3> <div class="spinner-grow" role="status"> <span class="visually-hidden"></span> </div> </body> </html>
该微调器使用currentColor通过文本颜色实用程序更改其外观。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h3>Growing color Spinners</h3> <div class="spinner-grow text-primary" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow text-secondary" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow text-info" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow text-dark" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow text-warning" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow text-success" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow text-light" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow text-danger" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow" role="status"> <span class="visually-hidden"></span> </div> </body> </html>
结盟
Bootstrap 微调器是用rem s、currentColor和display: inline-flex设计的。它们可以轻松调整大小、重新着色和对齐。
利润
对于简单的间距,请使用边距实用程序,例如.m-4。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h3>Margin</h3> <div class="spinner-border m-4" role="status"> <span class="visually-hidden"></span> </div> </body> </html>
放置
可以使用flexbox 实用程序、浮动实用程序或文本对齐实用程序来放置 Bootstrap 微调器。
柔性
使用 Flexbox 放置类来设置微调器的位置。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h5 class="text-center">Flex placement at start, center, end</h5> <div class="d-flex justify-content-start"> <div class="spinner-border" role="status"> <span class="visually-hidden"></span> </div> </div> <div class="d-flex justify-content-center"> <div class="spinner-border" role="status"> <span class="visually-hidden"></span> </div> </div> <div class="d-flex justify-content-end"> <div class="spinner-border" role="status"> <span class="visually-hidden"></span> </div> </div> </body> </html>
您可以使用弹性盒放置来更改微调器对齐方式。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="d-flex align-items-end mt-2"> <h5 class="text-center">Flex placement</h5> <div class="spinner-border ms-auto" role="status" aria-hidden="true"></div> </div> </body> </html>
漂浮
使用浮动放置类来设置微调器的位置。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h5>Float placement at start and end</h5> <div class="clearfix float-start mt-2"> <div class="spinner-border" role="status"> <span class="visually-hidden"></span> </div> </div> <div class="clearfix float-end"> <div class="spinner-border" role="status"> <span class="visually-hidden"></span> </div> </div> </body> </html>
文本对齐
使用.text-align放置类来设置微调器项目的位置。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h5 class="text-center">Text Align at start, center, end</h5> <div class="text-start"> <div class="spinner-border" role="status"> <span class="visually-hidden"></span> </div> </div> <div class="text-center"> <div class="spinner-border" role="status"> <span class="visually-hidden"></span> </div> </div> <div class="text-end"> <div class="spinner-border" role="status"> <span class="visually-hidden"></span> </div> </div> </body> </html>
尺寸
旋转器尺寸可用于创建各种尺寸的旋转器。
对于小型旋转器,请使用.spinner-border-sm和.spinner-grow-sm类。
对于中型旋转器,请使用.spinner-border-md和.spinner-grow-md类。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h5 class="mt-2">Small Size Spinner</h5> <div class="spinner-border spinner-border-sm text" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow spinner-grow-sm" role="status"> <span class="visually-hidden"></span> </div> <h5 class="mt-2">Medium Size Spinner</h5> <div class="spinner-border spinner-border-md" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow spinner-grow-md" role="status"> <span class="visually-hidden"></span> </div> </body> </html>
要根据需要修改尺寸,请使用自定义 CSS 或内联样式。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h5 class="mt-2">Spinner using custom CSS</h5> <div class="spinner-border" style="width: 2rem; height: 2rem;" role="status"> <span class="visually-hidden"></span> </div> <div class="spinner-grow" style="width: 2rem; height: 2rem;" role="status"> <span class="visually-hidden"></span> </div> </body> </html>
纽扣
按钮微调器用于显示当前正在处理的操作。如果需要,请将微调器元素文本替换为按钮文本。
使用.btn和.spinner-border类创建微调按钮。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h5 class="mt-2">Spinner Buttons</h5> <button class="btn btn-primary" type="button" disabled> <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="visually-hidden"></span> </button> <button class="btn btn-secondary" type="button" disabled> <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Wait... </button> </body> </html>
使用.btn和.spinner-grow类创建不断增长的微调按钮。
例子
您可以使用编辑和运行选项编辑并尝试运行此代码。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap - Spinners</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <h5 class="mt-2">Growing Spinner Buttons</h5> <button class="btn btn-primary" type="button" disabled> <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span> <span class="visually-hidden">Wait...</span> </button> <button class="btn btn-secondary" type="button" disabled> <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span> Wait... </button> </body> </html>