123

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <nav role="navigation">
  <ul class="nav">
    <li><a data-target="nav__one">1</a></li>
    <li><a data-target="nav__two">2</a></li>
  </ul>
</nav>

<nav class="nav__sec nav__one">
  <ul>
    <li>1 Link 1</li>
    <li>1 Link 2</li>
    <li>1 Link 3</li>
    <li>and so on ...</li>
  </ul>
</nav>


<nav class="nav__sec nav__two">
  <ul>
    <li>2 Link 1</li>
    <li>2 Link 2</li>
    <li>2 Link 3</li>
    <li>2 Link 4</li>
    <li>2 Link 5</li>
    <li>2 Link 6</li>
    <li>and so on ...</li>
  </ul>
</nav>

<main role="main">
  
  It and principles are tied to leave room for the point is unobtrusive. It does not it does not the other four parts? Good design process show respect towards the absence of data they are closer approximations to be arbitrary or stay at one level of british culture, these tasks that form and tolerant, that, design makes a very minimalist way something intelligible and going and confusion are discoverable truths, you go, and value, measured more than the whole thing about the leading edge in colour.
  <p>
    Clutter is worthwhile to say, 'yeah, nature's laws are like overheads, well, low resolution, and in colour makes a purpose are neither decorative objects we're playing. Good design. What was have a clutterfree product more than the mode of clutter and restrained, in trying to leave room for the value on so much that is to the absence of information that we have disconnected function.
  </p>
  http://www.designeripsum.com/
</main>
            
          
!
            
              body{
  padding:0;
  margin:0;
  font-size: 12px; /* pretty important */
}

[role="navigation"] {
  background-color: #1f2429;
  color: #FFF;
  font-size:2.8em;
  height: 100%;
  width: 60px;
  z-index: 2;
  position: fixed;
}

.nav {
  list-style:none;
  padding:0;
  margin:0;
  line-height:60px;
}

.nav li {
  text-align:center;
  cursor: pointer;
}

.nav__sec {
  background-color: #2b323a;
  position: fixed;
  height: 100%;
  z-index: 1;
  color: #FFF;
  width: 250px;
  margin-left: -20.8em;
  overflow: auto;
}

.nav__sec.show {
  margin-left: 5em;
}

[role="main"] {
  margin-left: 70px;
  font-size: 1.5em;
  padding-top:1em;
}

.nav__sec {
  -webkit-transition: 0.3s; 
  transition: 0.3s;
}
            
          
!
            
              //using jQuery but also works in Zepto

    function clearAll() {
			$('.nav__sec, nav a').removeClass('show');		
		};

		$('main').click(function() {
			clearAll();
		});

		$('.nav a').click(function(){
			var n = $(this);
			var r = $("." + n.data("target"));

			if(n.hasClass("show")){
				n.removeClass('show'), r.removeClass('show');

			} else {
				clearAll(), n.addClass('show'), r.addClass('show');
			}

		});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console