Pen Settings



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


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.


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.


<div class="canvasDiv">
	<canvas id="canvasOne" width="540" height="260"></canvas>
	<canvas id="canvasTwo" width="540" height="260"></canvas>

<a href="" target="_blank"><img id="logo" src=""></a>

<img id="badge" src="">
<img id="badge2" src="">


                html, body {
  background-color:rgba(255, 255, 255, 1.00);


#logo { 
	position: absolute;

.canvasDiv {
  position: relative;
  width: 960px;
  height: 400px;

canvas {
  background: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0);

#canvasOne {
  position: absolute;
  right: 5px;
  top: 5px;
  border: 1px solid grey;

#canvasTwo {
  position: absolute;
  left: 5px;
  bottom: 5px;
  border: 1px solid grey;

#badge, #badge2 {
  position: absolute;
#badge2 {
  left: 75px;



                // Create 2 Stages
var bottomStage = stageSetup("canvasOne", handleEvt)
  .set({name: "bottomStage"});
//bottomStage.enableDOMEvents(false);	// you can set this if the bottom stage is completely covered by the top stage to reduce the number of active event listeners.

var topStage = stageSetup("canvasTwo", handleEvt)
    name: "topStage",
    nextStage: bottomStage

// Add a square child to each stage.
bottomStage.addChild(makeSquare(30, 95, "#F00", handleEvt));
topStage.addChild(makeSquare(375, 30, "#0F0", handleEvt));

// Add a text object to each stage output the events
bottomStage.text = bottomStage.addChild(new createjs.Text("", "15px monospace", "#111")
  .set({x: 195, y: 30, lineHeight: 16.7}));
topStage.text = topStage.addChild(new createjs.Text("", "15px monospace", "#111")
  .set({x: 30, y: 30, lineHeight: 16.7}));

// Setup a Stage instance to work with the canvas
function stageSetup(canvasName, handler) {
  stage = new createjs.Stage(canvasName);
  // Add event listeners to display all the events.
  stage.on("stagemousedown", handler);
  stage.on("stagemouseup", handler);
  stage.on("mouseleave", handler);
  stage.on("mouseenter", handler);
  //stage.on("stagemousemove", handler);	// too noisy

  // Update the stage each tick
  createjs.Ticker.on("tick", stage);
  stage.log = [];
  return stage;

// Create a container with a shape that reports mouse events to a handler
function makeSquare(x, y, color, handler) {
  var container = new createjs.Container()
      name: "container",
      cursor: "pointer"

  var shape = container.addChild(new createjs.Shape())
    .set({name: "square", x: x, y: y});, 0, 135, 135);

  // Add events to the shape that reports to a handler
  container.on("mouseover", handler);
  container.on("mouseout", handler);
  container.on("dblclick", handler);
  container.on("click", handler);

  return container;

// Log functions that update text object on related stages with mouse event info
function handleEvt(evt) {
  var target =, 
      stage = target.stage, 
      log = stage.log;

  log.push(evt.type + " on " +
           + " x:" + evt.stageX.toFixed(0) 
           + " y:" + evt.stageY.toFixed(0));
  while (log.length > 12) { log.shift(); }
  stage.text.text = log.join("\n");

  if (evt.type === "mouseover") {
    target.alpha = 0.5;
  if (evt.type === "mouseout") {
    target.alpha = 1;