Pen Settings



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


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


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.


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.


                <button onClick="animateBox();">Animate Box</button>
<button onClick="resetBox();">Reset</button>
<div class="container">
  <div id="box" class="">


                .container {
  position: relative;
  height: 16em;
  margin: 1em 0;
  background: #eee;

#box {
  width: 1em;
  height: 1em;
  position: absolute;
  top: 1em;
  left: 1em;
  transform-origin: top left;
  background: #800;

#box.expanded {
  width: 4em;
  height: 4em;
  top: auto;
  left: auto;
  bottom: 1em;
  right: 1em;

.transitions-enabled {
  transition: all 1.2s;


                var box = document.getElementById('box');

function animateBox() {
  // Get the initial position.
  var first = box.getBoundingClientRect();

  // Move element to last position.

  // Read position again. Note: this forces a sync layout
  var last = box.getBoundingClientRect();

  // Calculate difference for properties you want to animate
  var scale = first.width / last.width,
      invertX = first.left - last.left,
      invertY = -
  // Invert. Use properties that are compositor-only, like transform or opacity. = 'translate(' + invertX + 'px,' + invertY + 'px) scale(' + scale + ')';

  // Wait for the next frame. This ensures all the style changes have taken hold.
  requestAnimationFrame(function() {

    // Add class that enables transition animations.

    // Removing transforms causes them to animate to ending position = '';

  // Clean up when transition is done
  box.addEventListener('transitionend', cleanUpAnimations);

function resetBox() {
  box.classList.remove('transitions-enabled', 'expanded');

function cleanUpAnimations() {