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

              
                <div id="container"></div>
<div id="nav">
  <a id="link-a" href="#">AAAAA</a>
  <a id="link-b" href="#">BBBBB</a>
  <a id="link-c" href="#">CCCCC</a>
</div>
<div id="a" class="box"></div>
<div id="b" class="box"></div>
<div id="c" class="box"></div>
              
            
!

CSS

              
                body, html {
  margin: 0;
  height: 100%;
}

#container {
  width: 100%;
  height: 100%;
  background: lightgray;
  position: relative;
}

#nav {
  position: fixed;
  left: 20px;
  top: 20px;
}

#link-a, #link-b, #link-c {
  display: inline-block;
  padding: 1em;
  color: white;
  background: black;
  text-decoration: none;
}

.box {
  width: 100%;
  height: 100%;
  position: absolute;
}

#a {
  background: cyan;
}

#b {
  background: yellow;
}

#c {
  background: magenta;
}
              
            
!

JS

              
                // Define some view elements to work with
var a = $("#a");
var b = $("#b");
var c = $("#c");

// Remove these views from the DOM
a.remove();
b.remove();
c.remove();

// This var will hold a reference to the current view
var currentView;

// Define some transitions 
  var offLeft = {
    left: "-100%"
  };
  var onHorizontal = {
    left: 0
  };

  var offRight = {
    left: "100%"
  };
  
  var offDown = {
    top: "100%"
  };
  var offUp = {
    top: "-100%"
  };
  
  var onVertical = {
    top: 0
  };
  
  // These combinations create transitions in four directions
  // Slide right: offRight, offLeft, onHorizontal
  // Slide left: offLeft, offRight, onHorizontal
  // Slide down: offDown, offUp, onVertical
  // Slide up: offUp, offDown, onVertical

// Some helper functions to create transitions in four directions
function pushLeft(newView) {
  showView(newView, offRight, offLeft, onHorizontal)
}

function pushRight(newView) {
  showView(newView, offLeft, offRight, onHorizontal)
}

function pushDown(newView) {
  showView(newView, offDown, offUp, onVertical);
}

function pushUp(newView) {
  showView(newView, offUp, offDown, onVertical);
}


function showView(newView, exit, start, enter) {
  // Hide Current View
  if (currentView) {
    currentView.animate(exit, 400, function() {
      this.remove();
    });
  }
  // Show New View
  currentView = newView;
  $("#container").append(currentView);
  currentView.css(start).animate(enter, 400, function() {

  });
}


// These functions make use of the new transition helper functions
$("#link-a").click(function(event) {
  pushRight(a);
});

$("#link-b").click(function(event) {
  pushRight(b);
});

$("#link-c").click(function(event) {
  pushRight(c);
});
              
            
!
999px

Console