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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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 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>

              
            
!

CSS

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

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

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

a{ color: #DB5361; }

.example-1{
  position: relative;
  height: 200px;
  margin: 1em 0;
  background: #BCE27F;
}

.example-1:before{
  content:'';
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 999;
  width: 150px;
  border-radius: 10px;
  border: solid 10px #96B566;
  transform: translate(-50%, -50%);
}

.example-1:after{
    content:'';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 15px;
    z-index: 999;
    border-radius: 50%;
    background: #F6FF97;
    animation-name: example-1;
    animation-duration: 2s;
    animation-direction: alternate;
    animation-timing-function: ease-in-out;    
    animation-iteration-count: infinite;
}

@keyframes example-1 {
  0% { transform: translate(-72.5px,-7.5px); }
  100% { transform: translate(58.5px,-7.5px); }
} 

.example-2{
  padding: 0 1em;
  border: solid 3px #96B566;
}

.example-2 #more{
  position: relative;
  padding: 1em;
  text-align: center;
  border: dashed 2px #96B566;
}

.example-2 #more:target:before{
  content:'';
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 999;
  width: 100px;
  border-radius: 10px;
  border: solid 5px #96B566;
  transform: translate(-50%, -50%);
}

.example-2 #more:target:after{
    content:'';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    z-index: 999;
    border-radius: 50%;
    border: solid 5px #F6FF97;
    animation-name: example-2;
    animation-duration: 1s;
    animation-direction: alternate;
    animation-timing-function: linear;   
    animation-iteration-count: infinite;    
}

.example-2 #more:target a{
    visibility: hidden;    
}

@keyframes example-2 {
  0% { transform: translate(-50px,-10px); }
  100% { transform: translate(30px,-10px); }
} 

.example-3{
  position: relative;  
}

.example-3:hover:before{
  content:'';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 40px;
  z-index: 999;
  border-radius: 20px;
  border: solid 10px #F6FF97;
  transform: translate(-50%, -50%);
}

.example-3:hover:after{
    content:'';
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    z-index: 999;
    background: #96B566;
    animation-name: example-3;
    animation-duration: 1s;
    animation-direction: alternate;
    animation-timing-function: linear;   
    animation-iteration-count: infinite;    
}

@keyframes example-3{
  0% { transform: translate(-40px,-10px); }
  100% { transform: translate(20px,-10px); }
} 

.example-4{
  position: relative;
  padding: 1em;
  margin: 1em 0;
  text-align: center;
  border: dashed 2px #96B566;
}

#page:target{
  position:absolute;
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  z-index: 99999;
  background:rgba(255,255,255,0.9);
}

#page:target{
  position:absolute;
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  z-index: 99999;
  background:rgba(255,255,255,0.9);
}

#page:target:before{
    content:'';
    position: absolute;
    z-index: 999;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #96B566;
    animation-name: example-4a;
    animation-duration: 1s;
    animation-direction: alternate;
    animation-timing-function: linear;   
    animation-iteration-count: infinite;  
}

#page:target:after{
    content:'';
    position: absolute;
    z-index: 999;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #BCE27F;
    animation-name: example-4b;
    animation-duration: 1s;
    animation-direction: alternate;
    animation-timing-function: linear;   
    animation-iteration-count: infinite;    
}

@keyframes example-4a{
  0% { transform: translate(-70px,-10px); }
  100% { transform: translate(-10px,-10px); }
} 

@keyframes example-4b{
  0% { transform: translate(70px,-10px); }
  100% { transform: translate(10px,-10px); }
} 
              
            
!

JS

              
                
              
            
!
999px

Console