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. 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

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

              
                <span class="menu-icon closed" id="menuBtn"></span>

<nav class="menu-container closed" id="menuContainer">
  <ul>
    <li><a href="#">Item 1</a></li>
    <li><a href="#">Item 2</a></li>
    <li><a href="#">Item 3</a></li>
  </ul>
</nav>
              
            
!

CSS

              
                /*styles for menu icon*/
.menu-icon {
  display: block;
	font-size: 0;
	background: none;
	border: none;
	width: 30px;
	height: 25px;
	position: relative;
  cursor: pointer;
}

.menu-icon,
.menu-icon:before,
.menu-icon:after {
  border-top: 3px solid #000;
	-webkit-transition: all .3s;
	-moz-transition: all .3s;
	transition: all .3s;
}

.menu-icon:before,
.menu-icon:after {
	position: absolute;
	content: "";
	display: block;
	left: 0;
	right: 0;
}

.menu-icon:before {
	top: 7px;
}

.menu-icon:after {
	top: 17px;
}

.menu-icon.opened {
	border-top-color: transparent;
}

.menu-icon.opened:after {
	-webkit-transform: rotate(45deg);
	-moz-transform: rotate(45deg);
	transform: rotate(45deg);
	top: 12px;
}

.menu-icon.opened:before {
	-webkit-transform: rotate(-45deg);
	-moz-transform: rotate(-45deg);
	transform: rotate(-45deg);
	top: 12px;
}

/*styles for menu container*/
.menu-container {
  padding-top: 20px;
  width: 300px;
}

.menu-container ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-container li {
  margin-bottom: 10px;
}

.menu-container a {
  display: block;
  padding: 10px 0;
  color: #fff;
  background: #ccc;
  text-decoration: none;
  text-align: center;
  font-family: sans-serif, arial;
}

.menu-container.closed {
  display: none;
}

.menu-container.opened {
  display: block;
}
              
            
!

JS

              
                var menuBtn = document.getElementById('menuBtn');
var menuContainer = document.getElementById('menuContainer');

var menuIconClosed = "menu-icon closed"; //class name for closed button
var menuIconOpened = "menu-icon opened"; //class name for opened button
var menuContClosed = "menu-container closed"; //class name for closed menu
var menuContOpened = "menu-container opened"; //class name for opened menu

menuBtn.onclick = function() {
  if (menuBtn.className == menuIconClosed) {
    menuBtn.className = menuIconOpened;
    menuContainer.className = menuContOpened;
  } else if (menuBtn.className == menuIconOpened) {
    menuBtn.className = menuIconClosed;
    menuContainer.className = menuContClosed;
  }
}
              
            
!
999px

Console