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

              
                <body>
  <nav class="main-navigation">
    <ul class="league-list">
      <li class="league">
        <button class="list-toggle js-list-toggle">American League</button>
        <ul class="division-list" aria-expanded="false">
          <li class="division">
            <button class="list-toggle js-list-toggle">East</button>
            <ul class="team-list" aria-expanded="false">
              <li class="team">
                <a href="orioles.html">Baltimore Orioles</a>
              </li>
              <li class="team">
                <a href="redsox.html">Boston Red Sox</a>
              </li>
              <li class="team">
                <a href="yankees.html">New York Yankees</a>
              </li>
              <li class="team">
                <a href="rays.html">Tampa Bay Rays</a>
              </li>
              <li class="team">
                <a href="bluejays.html">Toronto Blue Jays</a>
              </li>
            </ul>
          </li>
          <li class="division">
            <button class="list-toggle js-list-toggle">Central</button>
            <ul class="team-list" aria-expanded="false">
              <li class="team">
                <a href="whitesox.html">Chicago White Sox</a>
              </li>
              <li class="team">
                <a href="indians.html">Cleveland Indians</a>
              </li>
              <li class="team">
                <a href="tigers.html">Detroit Tigers</a>
              </li>
              <li class="team">
                <a href="royals.html">Kansas City Royals</a>
              </li>
              <li class="team">
                <a href="twins.html">Minnesota Twins</a>
              </li>
            </ul>
          </li>
          <li class="division">
            <button class="list-toggle js-list-toggle">West</button>
            <ul class="team-list" aria-expanded="false">
              <li class="team">
                <a href="astros.html">Houston Astros</a>
              </li>
              <li class="team">
                <a href="angels.html">Los Angeles Angels</a>
              </li>
              <li class="team">
                <a href="as.html">Oakland A&rsquo;s</a>
              </li>
              <li class="team">
                <a href="mariners.html">Seattle Mariners</a>
              </li>
              <li class="team">
                <a href="rangers.html">Texas Rangers</a>
              </li>
            </ul>
          </li>
        </ul>
      </li>
      <li class="league">
        <button class="list-toggle js-list-toggle">National League</button>
        <ul class="division-list" aria-expanded="false">
          <li class="division">
            <button class="list-toggle js-list-toggle">East</button>
            <ul class="team-list" aria-expanded="false">
              <li class="team">
                <a href="braves.html">Atlanta Braves</a>
              </li>
              <li class="team">
                <a href="marlins.html">Miami Marlins</a>
              </li>
              <li class="team">
                <a href="mets.html">New York Mets</a>
              </li>
              <li class="team">
                <a href="phillies.html">Philadelphia Phillies</a>
              </li>
              <li class="team">
                <a href="nationals.html">Washington Nationals</a>
              </li>
            </ul>
          </li>
          <li class="division">
            <button class="list-toggle js-list-toggle">Central</button>
            <ul class="team-list" aria-expanded="false">
              <li class="team">
                <a href="cubs.html">Chicago Cubs</a>
              </li>
              <li class="team">
                <a href="reds.html">Cincinnati Reds</a>
              </li>
              <li class="team">
                <a href="brewers.html">Milwaukee Brewers</a>
              </li>
              <li class="team">
                <a href="pirates.html">Pittsburgh Pirates</a>
              </li>
              <li class="team">
                <a href="cardinals.html">St Louis Cardinals</a>
              </li>
            </ul>
          </li>
          <li class="division">
            <button class="list-toggle js-list-toggle">West</button>
            <ul class="team-list" aria-expanded="false">
              <li class="team">
                <a href="diamondbacks.html">Arizona Diamondbacks</a>
              </li>
              <li class="team">
                <a href="rockies.html">Colorado Rockies</a>
              </li>
              <li class="team">
                <a href="dodgers.html">Los Angeles Dodgers</a>
              </li>
              <li class="team">
                <a href="padres.html">San Diego Padres</a>
              </li>
              <li class="team">
                <a href="giants.html">San Francisco Giants</a>
              </li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
  </nav>

</body>

              
            
!

CSS

              
                // Variables

$text-color: #444;
$border-color: rgba(black, 0.1);

// Mixins

@mixin accordion(
  // Defaults
  $duration: 0.5s,
  $easing: ease
  ) {
  position: relative; // ...so we can absolutely position the pseudoelement
  &:after {
    content: '\25bc'; // ‘Black Down-Pointing Triangle’
    position: absolute;
    right: 0.5em;
    transition: transform $duration $easing;
  }
  & + ul {
    max-height: 0;
    overflow: hidden;
    transition: max-height $duration $easing;
  }
  &.list-open {
    &:after {
      transform: rotateX(180deg);
    }
    & + ul {
      max-height: 100vh;
    }
  }
}

// SCSS

// Quickie global reset
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  color: $text-color;
  font-family: 'Helvetica', 'Arial', sans-serif;
}

ul {
  list-style: none;
  width: 15em;
}

button,
a {
  display: block;
  padding: 0.5em;
  border-bottom: 1px solid $border-color;
}

// Make a button look like a link
button {
  background: none;
  border: 0;
  border-bottom: 1px solid $border-color;
  color: $text-color;
  font-family: inherit;
  font-size: 1em;
  text-align: left;
  width: 100%;
  &:hover {
    cursor: pointer;
  }
}

a {
  color: $text-color;
  text-decoration: none;
}

.list-toggle {
  @include accordion;
}

.main-navigation {
  margin: 2em;
}

.league-list {
  background-color: #ccc;
}

.division-list {
  background-color: #ddd;
}

.team-list {
  background-color: #eee;
}

              
            
!

JS

              
                $(function() {

  $('.js-list-toggle').click(function() {
    if ($(this).hasClass('list-open')) {
      $(this).removeClass('list-open')
        .next().attr('aria-expanded', 'false');
    } else {
      $(this).addClass('list-open')
        .next().attr('aria-expanded', 'true');
    }
  });

});

              
            
!
999px

Console