Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <!--
Example of triggering a CSS animation from JavaScript. Modified from https://codepen.io/Orb89/pen/zvOEWM
-->

<div class="wrapper">
		  <div id="red-box">
        <span id="click-text">Click Me</span>
  </div>
</div>
              
            
!

CSS

              
                /* Set up our red box */
#red-box {
  height: 100px;
  width: 100px;
  background: red;
  margin: 0 auto;
  display: table;
  text-align: center;
  color: white;
}

/* Define the frames our animation and name the animation boxmorph */
@keyframes boxmorph {
  40%{
    height: 30px;
    width: 30px;
    background: green;
    border-radius: 50px;
  }
}

/* Adding this class will trigger the animation */
.animate {
  animation: boxmorph 5s;
}

/* Center text */
#click-text {
  display: table-cell;
  vertical-align: middle;
}

#wrapper{
  position: relative;  
}
              
            
!

JS

              
                /* Get the red box */
box_div = document.getElementById('red-box');

/* When the box is clicked, trigger the animation by adding the .animate class we defined in the CSS */
box_div.addEventListener('click', () => {
  console.log('Starting animation');
  box_div.classList.add('animate');
});

/* When the animation has ended, remove the .animate class so we can add it again when the box is clicked the next time (otherwise we can't retrigger the animation) */
box_div.addEventListener('animationend', () => {
  console.log('Animation endeded');
  box_div.classList.remove('animate');
});

              
            
!
999px

Console