cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

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

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

Code Indentation

     

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.

            
              
<a id="page" href="#"></a> 
<!-- only cause I can't put an id on the body -->
<h1>Zero element loading animations</h1>
<p>Unlike a lot of single element loading animations this example can be applied on almost any existing element just by adding a class.</p>
<div class="example-1"></div>
<p>This means they can even be applied using <code>:hover</code> or <code>:target</code>.</p>
<div class="example-2">
  <h2>Example</h2>
  <p>The old man knew he was going far out and he left the smell of the land behind and rowed out into the clean early morning smell of the ocean. He saw the phosphorescence of the Gulf weed in the water as he rowed over the part of the ocean that the fisherman called the great well because there was a sudden deep of seven hundred fathoms where all sorts of fish congregated because of the swirl the current made against the steep walls of the floor of the ocean. Here there were concentrations of shrimp and bait fish and sometimes schools of squid in the deepest holes and these rose close to the surface at night where all the wandering fish fed on them.</p>
  <p id="more"><a href="#more">Load more</a></p>
</div>
<p>Hover to load the rhino.</p>
<div class="example-3"><img src="//lorempixel.com/600/300/animals/1"><p style="text-align:center;">Note: Internet explorer does not have 'rhino load' capability.</p></div>

<div class="example-4"><a href="#page">click to apply to page</a></div>

            
          
!
            
              //This is not the best example of a mixin - it is just something to help modify examples on the fly. Sorry! 

@mixin loading($name, $big_radius:50,$little_radius:10,$big_stroke:10,$little_stroke:5,$speed:4s,$res:40) {
  &:before{
    content:'';
    position: absolute;
    top: 50%;
    left: 50%;
    width: ($big_radius*2) +px;
    height: ($big_radius*2) +px;
    z-index: 999;
    border-radius: 50%;
    border: solid $big_stroke+px rgba(10,120,255,.5);
    transform: translate( 0- $big_radius + px, 0- $big_radius +px);
  }
  &:after{
    content:'';
    position: absolute;
    top: 50%;
    left: 50%;
    width: $little_radius+px;
    height: $little_radius+px;
    z-index: 999;
    border-radius: 50%;
    border: solid $little_stroke+px rgba(255,255,255,.8);
    animation-name: #{$name} ;
    animation-duration: $speed;
    animation-iteration-count: infinite;
  }
  // This generates a lot of keyframes, but smaler than svg or img, can tune with $res
  @keyframes #{$name} {
    @for $i from 0 through $res {
      $x: floor( ($big_radius - ($big_stroke/2)) * cos( 2 * pi() * ($i / $res)) - ($little_radius/2) ); 
      $y: floor( ($big_radius - ($big_stroke/2)) * sin( 2 * pi() * ($i / $res)) - ($little_radius/2) );
      #{($i/$res)*100}% { transform: translate($x + px,$y + px); }
    }
  } 
}

*,:before,:after{
  box-sizing: border-box;
}

html{
  height:100%;
  background: #CAEDF2; 
}

body{
  width: 600px;  
  height:100%;
  margin:0 auto;
  font-family: 'Poiret One', cursive; 
  color: #333;
}

.example-1{
  height: 200px;
  margin: 1em 0;
  background: rgba(100,230,230,0.5);
  border: solid 3px rgb(100,230,230);
  position: relative;
  @include loading('example-1',80,20,20,10);
}

.example-2{
  margin: 1em 0;
  padding: 0 1em;
  border: solid 3px rgb(100,230,230);
}

#more{
  position: relative;
  display: block;
  margin: 1em 0;
  padding: 1em;
  height: 65px;
  text-align: center;
  border: dashed 3px rgb(100,230,230);
}

#more:target{
  position: relative;
  background: rgba(100,230,230,0.5);
  border: solid 3px rgb(100,230,230);
  @include loading('example-2',20,10,5,5,1s);
}

#more:target a{
  display: none;
}

.example-3{
  position: relative;
  margin: 1em 0;
  cursor:pointer;
}
.example-3:hover{
  @include loading('example-3',30,20,8,5,2s);
}

.example-4{
  position: relative;
  display: block;
  margin: 1em 0;
  padding: 1em;
  height: 65px;
  text-align: center;
  border: dashed 3px rgb(100,230,230);
}

#page:target{
  position:absolute;
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  z-index: 99999;
  background:rgba(255,255,255,0.9);
  @include loading('example-4',60,20,15,8,3s);
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console