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.


                <div class="island">
  <p>A nifty little <a href="">jQuery</a> or <a href="">Zepto</a> plugin for the simplest of sliding views.</p>

<div class="views">

  <div class="view views-nav" id="nav">

        Because these anchors resolve to actual elements, we don't have to
        provide a value for the 'data-pushview' or 'data-popview' attributes.
        This is extra-nifty because it means our page will be functional
        even if JavaScript fails to load or is disabled.
      <li><a href="#what" data-pushview>What it does</a></li>
      <li><a href="#how" data-pushview>How it works</a></li>
      <li><a href="#where" data-pushview>Where to get it</a></li>

  <div class="views-main">

    <div class="view" id="what">
      <div class="view-content">
        <h2>What it does</h2>
        <p>Sliding views let you present content in distinct, bite-sized chunks while maintaining hierarchy through the use of spacial animation. They look neat, too.</p>
        <p>There are many wonderful JavaScript frameworks out there that pull this off beautifully... but they can get kind of complicated. When your needs are simple or responsive, <b>SimpleSlideView</b> may do the trick.</p>
        <ul class="view-nav clearfix">
          <li class="view-nav-contents pull-left"><a href="#nav" data-popview>Contents</a></li>
          <li class="view-nav-next pull-right"><a href="#how" data-pushview>How it works</a></li>

    <div class="view" id="how">
      <div class="view-content">
        <h2>How it works</h2>
        <p>The plugin only needs a few ingredients to work:</p>
          <li>Either <a href="">jQuery</a> or <a href="">Zepto</a>.</li>
          <li>A containing element.</li>
          <li>Some special <code>data-pushview</code> and <code>data-popview</code> attributes on elements you want to trigger slides.</li>
        <p>Then call...</p>
        <p>...and bob&rsquo;s your uncle!</p>
        <p>Okay, there&rsquo;s a <em>little</em> more to it than that (especially if you want to customize a bunch of stuff). But not much.</p>
        <ul class="view-nav clearfix">
          <li class="view-nav-contents pull-left"><a href="#nav" data-popview>Contents</a></li>
          <li class="view-nav-next pull-right"><a href="#where" data-pushview>Where to get it</a></li>

    <div class="view" id="where">
      <div class="view-content">
        <h2>Where to get it</h2>
        <p>All this (plus documentation and source files) can be yours <em>right now</em> thanks to the magic of GitHub and open source software. Isn&rsquo;t life great?</p>
        <ul class="view-nav clearfix">
          <li class="view-nav-contents pull-left"><a href="#nav" data-popview>Contents</a></li>
          <li class="pull-right"><a class="btn" href="">View on GitHub</a></li>



<div class="island byline clearfix">
  <p class="pull-left">Made by <a href="">Cloud Four</a></p>
  <p class="pull-right"><a href="responsive.html">Responsive demo &raquo;</a></p>




                // This pen was created in response to a blog comment:

// The question:
// > Maybe I’m just missing it, but is there a way to link
// > in to a specific view from another page? For example, 
// > I’d like to link from index.html to 
// > simpleslideview.html#view-2. Currently it just takes
// > you to the “contents” view.

// Here we have the same source as the demo. The following
// elements have IDs and are thus selectable based on a
// URL hash: #nav, #what, #how, #where

// Because of that, we can pass it along to our plugin
// initialization using the `activeView` option.

// Because Codepens use a lot of iframes, I'm just
// going to set this window's location hash to '#how'.
// Just imagine we've arrived on this page with this
// hash in the URL. (Translation: "Pay no attention to
// the man behind the curtain!!")
window.location.hash = '#how';

// Here's where the actual fun starts. First, let's
// retrieve the hash.
var hash = window.location.hash;

// Now that I've retrieved it, I'm going to
// clear the hash to avoid unnecessary page jumping
// and stuff.
window.location.hash = '';

// Let's also do some validation. We want to make sure:
// * The hash is defined and truthy
// * The hash has length
// * The hash isn't just '#'
// * The hash actually matches elements on the page
// If any of these things don't pan out, we want our
// plugin to pretend this never happened.
if (!hash || !hash.length || hash == '#' || !$(hash).length) {
  hash = null;

// We're ready to initialize SimpleSlideView!
  // This is from the demo
  duration: 250,
  // Pass along the hash value we determined earlier
  // as the initial activeView selector
  activeView: hash

// Okay, caveat time!

// Hashes are a total pain in the butt to manage.
// You can read about some of our headaches with this
// stuff here:

// Hopefully this is enough to get you started.