Bootstrap中如何添加Loading效果

分类:知识百科 日期: 点击:0

使用Bootstrap添加Loading效果

Bootstrap是一个开源的用于快速开发Web应用程序的前端框架,它提供了一系列的CSS样式和JavaScript插件,使开发者可以快速构建网页。Bootstrap中也可以添加Loading效果,以下是具体的使用方法:

1.使用Bootstrap的Spinner加载器

Bootstrap提供了一系列的Spinner加载器,可以用来显示加载的进度。要使用Spinner加载器,要引入Bootstrap的CSS文件:


在页面上添加加载器:

添加以下CSS样式:

.loader {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: #fefefe;
  opacity: 0.9;
  z-index: 9999;
}
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -50px;
  margin-top: -50px;
  text-align: center;
}
.double-bounce1, .double-bounce2 {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: #333;
  opacity: 0.6;
  position: absolute;
  top: 0;
  left: 0;
  animation: sk-bounce 2.0s infinite ease-in-out;
}
.double-bounce2 {
  animation-delay: -1.0s;
}
@keyframes sk-bounce {
  0%, 100% { 
    transform: scale(0.0) 
  }
  50% { 
    transform: scale(1.0) 
  }
}

这样,就可以在页面上添加Loading效果了。

2.使用Bootstrap的Progress Bar

Bootstrap也提供了Progress Bar,可以用来显示加载的进度。要使用Progress Bar,要引入Bootstrap的CSS文件:


在页面上添加Progress Bar:

60%

添加以下CSS样式:

.loader {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: #fefefe;
  opacity: 0.9;
  z-index: 9999;
}
.progress {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -50px;
  margin-top: -50px;
  text-align: center;
}

这样,就可以在页面上添加Progress Bar了。

3.使用Bootstrap的Overlay

Bootstrap还提供了Overlay,可以用来添加Loading效果。要使用Overlay,要引入Bootstrap的CSS文件:


在页面上添加Overlay:

添加以下CSS样式:

.overlay {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: #fefefe;
  opacity: 0.9;
  z-index: 9999;
}
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -50px;
  margin-top: -50px;
  text-align: center;
}
.double-bounce1, .double-bounce2 {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: #333;
  opacity: 0.6;
  position: absolute;
  top: 0;
  left: 0;
  animation: sk-bounce 2.0s infinite ease-in-out;
}
.double-bounce2 {
  animation-delay: -1.0s;
}
@keyframes sk-bounce {
  0%, 100% { 
    transform: scale(0.0) 
  }
  50% { 
    transform: scale(1.0) 
  }
}

这样,就可以在页面上添加Overlay了。

以上就是使用Bootstrap添加Loading效果的方法

标签:

版权声明

1. 本站所有素材,仅限学习交流,仅展示部分内容,如需查看完整内容,请下载原文件。
2. 会员在本站下载的所有素材,只拥有使用权,著作权归原作者所有。
3. 所有素材,未经合法授权,请勿用于商业用途,会员不得以任何形式发布、传播、复制、转售该素材,否则一律封号处理。
4. 如果素材损害你的权益请联系客服QQ:77594475 处理。