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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <nav id="layered-nav">
  <div class="main option">
    <h2>Colors</h2>
  </div>
  <div class="section primary-section option">
    <h2>Primary</h2>
  </div>
  <div class="section secondary-section option">
    <h2>Secondary</h2>
  </div>
  <div class="section tertiary-section option">
    <h2>Tertiary</h2>
  </div>
  <div class="primary red option">
    <h2>Red</h2>
  </div>
  <div class="primary yellow option">
    <h2>Yellow</h2>
  </div>
  <div class="primary blue option">
    <h2>Blue</h2>
  </div>
  <div class="secondary green option">
    <h2>Green</h2>
  </div>
  <div class="secondary orange option">
    <h2>Orange</h2>
  </div>
  <div class="secondary purple option">
    <h2>Purple</h2>
  </div>
  <div class="tertiary red-orange option">
    <h2>Red-Orange</h2>
  </div>
  <div class="tertiary yellow-orange option">
    <h2>Yellow-Orange</h2>
  </div>
  <div class="tertiary red-purple option">
    <h2>Red-Purple</h2>
  </div>
  <div class="tertiary blue-purple option">
    <h2>Blue-Purple</h2>
  </div>
  <div class="tertiary blue-green option">
    <h2>Blue-Green</h2>
  </div>
  <div class="tertiary yellow-green option">
    <h2>yellow-green</h2>
  </div>
</nav>

<div id="back-button">
  <h2>Back</h2>  
</div>

              
            
!

CSS

              
                /* Set the containing element to flex
 * with a flow of row wrap.
 */
#layered-nav {
  display: flex;
  flex-flow: row wrap;
}

/* Everything below this comment exists 
 * purely for styling.
 */

.option {
  height: 150px;
  width: 150px;
  color: #fff;
  text-align: center;
  border-radius: 50%;
  margin: 10px;
}

#back-button {
  margin-left: 50px;
}

h2 { padding-top: 40px; }

.main, 
.section { background-color: #a9a9a9; }

/* Colors */
.red { background-color: red; }
.yellow { background-color: yellow; }
.blue { background-color: blue; }
.orange { background-color: orange; }
.green { background-color: green; }
.purple { background-color: purple; }
.red-orange { background-color: #FE6501; }
.yellow-orange { background-color: #FECC01; }
.red-purple { background-color: #B701DB; }
.blue-purple { background-color: #5601FF; }
.blue-green { background-color: #00CDCD; }
.yellow-green{ background-color: #3EFF01; }

              
            
!

JS

              
                // First, we create a function to hide everything.
hideAll = function() {
  $( '.option' ).hide();
}

// Next we set the default behavior
$( document ).ready( function() {
  hideAll();
  $( '.main' ).show();
});

// Then we set the behavior of our reset button
$( '#back-button' ).click( function() {
  hideAll();
  $( '.main' ).show();
});

// Lastly, we set the click behavior of all of our options
$( '.main' ).click( function() {
  hideAll();
  $( '.section' ).show();
});

$( '.primary-section' ).click( function() {
  hideAll();
  $( '.primary' ).show();
});

$( '.secondary-section' ).click( function() {
  hideAll();
  $( '.secondary' ).show();
});

$( '.tertiary-section' ).click( function() {
  hideAll();
  $( '.tertiary' ).show();
})


              
            
!
999px

Console