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

              
                		<button id="btnAddCats">Make this page more awesome!</button>
<div id="log"></div>
<div id="cats"></div>
              
            
!

CSS

              
                #cats {
  width: 300px;
}
              
            
!

JS

              
                // Listen for postMessage events.
window.addEventListener("message", receiveMessage, false);

// A variable for storing our parent message event so we can
// establish two-way communication.
var parentMessageEvent;

function receiveMessage(event) {
  // Let's make sure the sender of this message is who we think it is.
  if (event.origin !== "http://deanpdx.com") {
    return;
  }
  var object = JSON.parse(event.data);
  appendToLog('Received postMessage.');
  appendToLog('Origin: ' + event.origin);
  appendToLog('Event: ' + object.event);
  appendToLog('Message: ' + object.message);
  // Store parent message event for two-way communication
  parentMessageEvent = event;
  sendResizeToParentWindow();
}

function appendToLog(message) {
  $('#log').append('<p>' + message + '</p>');
}

function sendResizeToParentWindow() {
  if (parentMessageEvent != undefined) {
    // Note: Chrome is fine with sending JSON objects as the message data
    // but some browsers (*glares at IE*) don't like it.  So, to make this
    // work on all browsers I am stringifying my objects and JSON.parsing them
    // on the other side.
    parentMessageEvent.source.postMessage(JSON.stringify({
      event: 'resize',
      height: $(document).height()
    }), parentMessageEvent.origin);
  }
};

// When the user wants to make the page more awesome, you know what to do...
$('#btnAddCats').click(function() {
  var width = Math.floor((Math.random() * 300) + 100);
  var height = Math.floor((Math.random() * 300) + 100);
  $('<img src="https://placekitten.com/' + width + '/' + height + '" alt="Adorable kitten">').load(function() {
    $(this).appendTo('#cats');
    sendResizeToParentWindow();
  });
});
              
            
!
999px

Console