[摘要]在web前端开发过程中,作为站长可能要考虑到,页面如果出现正在加载状态时该如何用css来展示等待加载的样式,一个好看的css网页加载动画可以减少用户等待过程中的乏味时刻。那么本篇文章就给大家介绍cs...
在web前端开发过程中,作为站长可能要考虑到,页面如果出现正在加载状态时该如何用css来展示等待加载的样式,一个好看的css网页加载动画可以减少用户等待过程中的乏味时刻。那么本篇文章就给大家介绍css加载中动画具体是如何实现的问题?
纯css代码实现页面加载中样式:
一、条形波动样式的css加载动画代码示例如下:
<div class="spinner">
  <div class="re1"></div>
  <div class="re2"></div>
  <div class="re3"></div>
  <div class="re4"></div>
  <div class="re5"></div>
</div>
.spinner {
  margin: 100px auto;
  width: 50px;
  height: 60px;
  text-align: center;
  font-size: 10px;
}
 
.spinner > div {
  background-color: #67CF22;
  height: 100%;
  width: 6px;
  display: inline-block;
   
  -webkit-animation: stretchdelay 1.2s infinite ease-in-out;
  animation: stretchdelay 1.2s infinite ease-in-out;
}
 
.spinner .re2 {
  -webkit-animation-delay: -1.1s;
  animation-delay: -1.1s;
}
 
.spinner .re3 {
  -webkit-animation-delay: -1.0s;
  animation-delay: -1.0s;
}
 
.spinner .re4 {
  -webkit-animation-delay: -0.9s;
  animation-delay: -0.9s;
}
 
.spinner .re5 {
  -webkit-animation-delay: -0.8s;
  animation-delay: -0.8s;
}
 
@-webkit-keyframes stretchdelay {
  0%, 40%, 100% { -webkit-transform: scaleY(0.4) }  
  20% { -webkit-transform: scaleY(1.0) }
}
 
@keyframes stretchdelay {
  0%, 40%, 100% { 
    transform: scaleY(0.4);
    -webkit-transform: scaleY(0.4);
  }  20% { 
    transform: scaleY(1.0);
    -webkit-transform: scaleY(1.0);
  }
}