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

              
                <div 
     id="square1"
     class="square red"></div>
<div 
     id="square2"
     class="square blue"></div>

<div 
     id="square3"
     class="square green"></div>

<div 
     id="square4"
     class="square yellow"></div>

<button id="start">
  Start
</button>

<button id="reset">
  Reset
</button>
              
            
!

CSS

              
                .square {
  width: 50px;
  height: 50px;
  margin-bottom: 5px;
}

.red { background: tomato; }
.blue { background: blue; }
.green { background: green; }
.yellow { background: yellow; }

.animate1 {
  transform: translateX(500px);
  background: black;
  transition: all 2s 0.25s;
  transition-timing-function: ease-in; 
}

.animate2 {
  transform: translateX(500px);
  background: tomato;
  transition: transform 2s 0.25s ease-in,
              background 3s 0.1s ease-out;
}

.animate3 {
  transform: translateX(500px);
  transition: transform 2s 0.25s ease-in-out;
}

.animate4 {
  transform: translateX(500px);
  transition: transform 2s 0.25s;
  transition-timing-function: cubic-bezier(.17,.67,.83,.67);
}
              
            
!

JS

              
                document.addEventListener("DOMContentLoaded", (event) => { 
  
  const start = document.getElementById('start');
  const reset = document.getElementById('reset');
  const square1 = document.getElementById('square1');
  const square2 = document.getElementById('square2');
  const square3 = document.getElementById('square3');
  const square4 = document.getElementById('square4');

  start.addEventListener("click", ()=>{
    // Animation 1
    square1.classList.add('animate1');
    // Animation 2
    square2.className += ' animate2';
    // Animation 3
    square3.className += ' animate3';
    // Animation 4
    square4.className += ' animate4';
  });
  
  reset.addEventListener("click", ()=>{
    // Animation 1
    square1.classList.remove('animate1');
    // Animation 2
    square2.classList.remove('animate2');
    // Animation 3
    square3.classList.remove('animate3');
    // Animation 4
    square4.classList.remove('animate4');
  });
  
  
}); 
              
            
!
999px

Console