Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                a href="http://www.zhangxinxu.com/wordpress/2014/04/css3-pie-loading-waiting-animation/" 看了这篇文章受启发,写了此程序
br

p 与原文不同在于:
ul
  li 使用的是纯CSS,无图片,原文的外面那条线使用了图片;
  li 中间的饼状图只使用了一个DIV,原文使用了多个,而且还复制了一次;
  li 只用了两个动画帧,复用了其中的一个;
  li style="color:red;" 
    | 2014.6.12 此处我忽略了一点,就是应该从暗切换到亮后还需要再从亮切换到暗,这个我再想想方案:
    ul
      li 使用原文的复制一遍DOM,分别设置不同的前后背景,不同的间隔显示
      li 
        | 使用两倍的动画时间,这样动画帧要复杂点 =>  
        a target="_parent" href="https://codepen.io/qiu8310/pen/JLxAB" style="font-weight:bold;" 点此查看升级版
      li 使用 Javascript 去监听动画,切换颜色(会复杂点,主要是我在动画的中间也用CSS切换过颜色) 


div.loading-pan
  div.spin-line
    i
  div.spin-pan
              
            
!

CSS

              
                @import "compass/css3";



$fg-color: #01FF70;
$bg-color: #3D9970;
$pan-size: 100px;
$line-size: 130px;
$line-border: 10px;
$line-start-color: rgb(132, 203, 177);
$loading-bg-color: white;
$anim-time: 5s;

@mixin spin-pan($pan-size, $fg-color, $bg-color, $anim-time: .8s) {
  $half-pan-size: $pan-size / 2;

  position: relative;
  display: block;
  width: $pan-size;
  height: $pan-size;
  border-radius: 50%;

  background-color: $fg-color;

  &::before,
  &::after {
    position: absolute;
    display: block;
    content: " ";
    width: $half-pan-size;
    height: $pan-size;
    background-color: $bg-color;
  }

  &::before {
    border-radius: $half-pan-size 0 0 $half-pan-size;

    transform-origin: right center;
    animation: spin-circle $anim-time infinite linear;
  }

  &::after {
    left: $half-pan-size;
    border-radius: 0 $half-pan-size $half-pan-size 0;

    transform-origin: left center;
    animation: spin-pan-after $anim-time infinite steps(1, end);
  }
}

@mixin spin-line($line-size, $line-border, $line-start-color, $bg-color: white, $anim-time: .8s) {

  $line-mid-color: lighten($line-start-color, 20%);
  $line-end-color: lighten($line-start-color, 100%);
  $half-line-size: $line-size / 2;

  position: relative;
  width: $line-size;
  height: $line-size;


  &::before,
  &::after {
    content: " ";
    display: block;
    position: absolute;
    background: $bg-color;
    width: $half-line-size;
    height: $line-size;
  }
  // 右半圆,从上到下渐变
  &::after {
    background-image: linear-gradient(top, $line-start-color 0%, $line-mid-color 100%);
    right: 0;
    border-radius: 0 $half-line-size $half-line-size 0;
  }

  // 左半圆,从下到上渐变
  &::before {
    background-image: linear-gradient(bottom, $line-mid-color 0%, $line-end-color 100%);
    left: 0;
    border-radius: $half-line-size 0 0 $half-line-size;
  }

  // 里面的一层 mask
  & > i {
    display: block;
    width: $line-size - $line-border;
    height: $line-size - $line-border;
    border-radius: 50%;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    margin: auto;
    z-index: 10;
    background-color: $bg-color;
  }

  // 旋转
  animation: spin-circle $anim-time infinite linear;
}


.spin-pan {
  @include spin-pan($pan-size, $fg-color, $bg-color, $anim-time);
}

.spin-line {
  @include spin-line($line-size, $line-border, $line-start-color, $loading-bg-color, $anim-time);
}

.loading-pan {
  position: relative;
  width: $line-size;
  height: $line-size;
  margin: 0 auto;

  .spin-pan {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;

  }
}


@keyframes spin-circle {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg);   }
}

@keyframes spin-pan-after {
  0% {
    background-color: $bg-color;
    transform: rotate(0deg);
  }
  50%,
  100% {
    background-color: $fg-color;
    transform: rotate(180deg);
  }
}






body {
  width: 650px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 10px;
  text-align: center;
  p {
    text-align: left;
  }
  ul {
    margin-bottom: 15px;
    text-align: left;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console