startv

Quite perfect CSS circle filling

A Pen By Captain Anonymous

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource
via CSS Lint

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource
via JS Hint

Code Indentation

     

Save Automatically?

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

Want a Run Button?

If active, the preview will update automatically when you change code.

HTML

            
              <div class="wrapper">
  <div class="pie spinner"></div>
  <div class="pie filler"></div>
  <div class="mask"></div>
</div>​ 
            
          
!

CSS

            
              @import "compass/css3";

/* This variable set the animation duration. */
$animation-duration : 10s;

* { box-sizing:border-box; }

/* The whole thing is responsive. Just make sure to specify both width and height on the parent element, and more importantly, make sure both values are the same. */ 
.wrapper { 
  width:250px;
  height:250px;
  margin:50px auto;
  position:relative; /* Allows absolute positionning for children. */
  background:white; 
}

.pie {
  /* Don't change anything */
  width: 50%;
  height: 100%;
  transform-origin: 100% 50%;
  position: absolute;
    
  /* Change what you want there */
  background: #08C;
  border: 20px solid rgba(0,0,0,0.4);
}

.spinner {
/* Thanks @Joshua Hibbert for the border-radius trick */
  background: #555;
  border-radius: 100% 0 0 100% / 50% 0 0 50%;
  z-index: 200;
    
  /* Change the border if you want */
  border-right:none;
    
  /* If you want to change the rotation duration, make sure to change it on the 3 animation properties and more importantly, make sur the 3 values are the same */
  animation: rota $animation-duration linear infinite;
}

/* You can pause the animation by hovering it, pretty neat huh ? */

.wrapper:hover .spinner,
.wrapper:hover .filler, 
.wrapper:hover .mask {
    animation-play-state: paused;    
}

/* You can put element on the circle, it works pretty fine. Try enabling this block of code to see it in action. */
/*
.spinner:after {
    position:absolute;
    width:10px;
    height:10px;
    background:#fff;
    border:1px solid rgba(0,0,0,0.5);
    box-shadow: inset 0 0 3px rgba(0,0,0,0.2);
    border-radius:50%;
    top:10px;
    right:10px;   
    content:"";
}*/

.filler {
  border-radius: 0 100% 100% 0 / 0 50% 50% 0; 
  left: 50%;
  opacity: 0;
  z-index: 100;
  animation: fill $animation-duration steps(1,end) infinite;
    
  border-left: none;
}

.mask {
  /* Don't change anything */
  width: 50%;
  height: 100%;
  position: absolute;
  background: #ccc;
  opacity: 1;
  z-index: 300;
  animation: mask $animation-duration steps(1,end) infinite;
}

@keyframes rota {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes mask {
  0% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes fill {
  0% { opacity: 0; }
  50%, 100% { opacity: 1; }
} 
            
          
!

JS

            
              
            
          
!
999px
Loading ..................

Console