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.

            
              <div id="site-wrapper">
  
   <div id="site-canvas">
    
     <div id="site-menu">
       <a href="#" class="toggle-nav" style="color: pink; font-size: 20px;"><i class="fa fa-times"></i></a>
       <h2>My Menu</h1>
       <p class="lead">Put any HTML you want here.</p>
       <p>Style it however you want.</p>
       
       <ul>
         <li>Free to scroll up and down</li>
         <li>But not left and write</li>
       </ul>
     </div>
     
    
     
     <a href="#" class="toggle-nav btn btn-lg btn-success" id="big-sexy"><i class="fa fa-bars"></i> Toggle Nav</a>
     
     <h1 class="text-center">Off Canvas Menu Tutorial</h1>
     
     <p class="lead text-center">Basic demo showing how to easily implement an Off Canvas Menu by <a href="https://scotch.io/tutorials/off-canvas-menus-with-css3-transitions-and-transforms">scotch.io</a>.</p>
    
    
    
  </div>

</div>
            
          
!
            
              /*
* Uses Font Awesome and Bootstrap 3
* Both aren't required for this demo
*/
#site-wrapper {
  position: relative;
  overflow: hidden;
  width: 100%;
  
  height: 5000px; /* Temp: Simulates a tall page. */
}
#site-canvas {
  width: 100%;
  height: 100%;
  position: relative;
  
  -webkit-transform: translateX(0);
  transform: translateX(0);
  
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  
  -webkit-transition: 300ms ease all;
  transition: 300ms ease all;
 
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;

  
  
    
  padding: 5% 0; /* Temp: Just spacing. */
}
.show-nav #site-canvas {
  -webkit-transform: translateX(300px);
  transform: translateX(300px);
  
  -webkit-transform: translate3d(300px, 0, 0);
  transform: translate3d(300px, 0, 0);
}
#site-menu {
  width: 300px;
  height: 100%;
  position: absolute;
  top: 0;
  left: -300px;
  background: #428bca;
  padding: 15px;
}







/* Just styles... Not relevant to demo */
body {
  box-shadow: inset 0 0 100px rgba(0,0,0,.5);
  background-color: #333;
  color: #fff;
}
#big-sexy {
  display: block;
  width: 300px;
  margin: 0 auto;
  font-size: 40px;
  font-weight: 300;
}
            
          
!
            
              /*
* Uses jQuery!!!!111one
*/


/*====================================
=            ON DOM READY            =
====================================*/
$(function() {
  
    // Toggle Nav on Click
    $('.toggle-nav').click(function() {
        // Calling a function in case you want to expand upon this.
        toggleNav();
    });

  
});


/*========================================
=            CUSTOM FUNCTIONS            =
========================================*/
function toggleNav() {
    if ($('#site-wrapper').hasClass('show-nav')) {
        // Do things on Nav Close
        $('#site-wrapper').removeClass('show-nav');
    } else {
        // Do things on Nav Open
        $('#site-wrapper').addClass('show-nav');
    }

    //$('#site-wrapper').toggleClass('show-nav');
}
            
          
!
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