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

              
                <a id="mobile-menu-toggle" href="#">Menu</a>

<nav id="main-nav" class="closed">
  <ul>
    <li><a href="#">One</a></li>
    <li><a href="#">Two</a></li>
    <li><a href="#">Three</a></li>
    <li><a href="#">Four</a></li>
    <li><a href="#">Five</a></li>
  </ul>
</nav>



              
            
!

CSS

              
                @import "compass/css3";

body{
  width: 70%;
  margin: 0 auto;
  padding-top: 20px;
}
#mobile-menu-toggle{
  color: #990000;
  background: #eee;
  display:block;
  width: 50px;
  padding: 10px;
  border-bottom: solid 1px #ccc;
  text-decoration: none;
  text-transform: uppercase;
}

#main-nav{

/* 	
    Setting up CSS for the menu toggle.
		We'll use CSS transitions for the animation, 
    where supported
*/
  .js.csstransitions & {
    height: 0;
    overflow: hidden;
    @include transition(all .2s ease);
    &.open{
			height: 300px; 
      /* The need for set pixel height is a flaw in this CSS animation technique.
      Height 100% doesn't work.
      */
      
		}
  }
  /* and set up a fall back to jQuery where it's not */
  .js.no-csstransitions &{
		display: none;
	}

/* Basic styles */
  ul{
    list-style: none;
    width: 250px;
    margin:0;
    padding: 0;
      li{
        padding: 20px;
        background: #eee;
        border-top: solid 1px #ccc;
        &:first-child{
          border: 0;
        }
      a{
        text-decoration:none;
        color: #545454;
      }
    }
  }
}


              
            
!

JS

              
                var main_nav = $('#main-nav');
var menu_toggle = $('#mobile-menu-toggle');

if(Modernizr.csstransitions){
  // CSS Class toggles where transitions are supported 
  menu_toggle.click(function(){
    main_nav.toggleClass('open');
    main_nav.toggleClass('closed');
  });
} else{
  // Good old slideToggle for everybody else
  menu_toggle.click(function(){
    main_nav.slideToggle(200);
  });
}
              
            
!
999px

Console