首页 > Web开发 > 详细

css 简易 loading 加载图

时间:2019-03-14 18:33:32      阅读:285      评论:0      收藏:0      [点我收藏+]

使用 css 的 animation ,可以做一个转圈的 loading 图,省去了使用 gif 图的麻烦。

为了力求精简,以下 css 样式都是集成在一个类上,

.loading{
    display: inline-block;
    height: 10px;
    width: 10px;
    border-radius: 50%;
    border: 2px solid #999;
    border-bottom-color: transparent;
    -webkit-animation: loading 0.75s linear infinite;
    animation: loading 0.75s linear infinite;
    // 位置相关
    margin: 6px;
    vertical-align: middle;
}
@-webkit-keyframes loading {
    0% { -webkit-transform: rotate(0deg); }
    50% { -webkit-transform: rotate(180deg); }
    100% { -webkit-transform: rotate(360deg); }
}
@keyframes loading {
    0% { -webkit-transform: rotate(0deg); }
    50% { -webkit-transform: rotate(180deg); }
    100% { -webkit-transform: rotate(360deg); }
}

如下:

技术分享图片技术分享图片

或:

.dot{
      display: block;
      width: 32px;
      height: 32px;
      position: relative;

      margin: 10px auto;
    }
    .dot::before,.dot::after{
      content: ‘‘;
      display: block;
      width: 50%;
      height: 50%;
      border-radius: 50%;
      background: #98bff6;
      position: absolute;
      top: 50%;
      left: 50%;
    }
    .dot::before{
      opacity: 0.6;
      transform: scale(2);
      animation: bigDot 2s infinite;
    }
    .dot::after{
      opacity: 0.4;
      transform: scale(0.1);
      animation: smallDot 2s infinite;
    }
    @keyframes bigDot {
      0% { transform: scale(2) }
      50% { transform: scale(0) }
      100% { transform: scale(2) }
    }
    @keyframes smallDot {
      0% { transform: scale(0) }
      50% { transform: scale(2) }
      100% { transform: scale(0) }
    }

如下:

技术分享图片技术分享图片技术分享图片

 

 

 

 

-- end --

css 简易 loading 加载图

原文:https://www.cnblogs.com/_error/p/10532081.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!