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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="page-wrap">
  <button class="offcanvas-toggle">Open offcanvas here</button>

  <h1>Simple HTML, LESS, jQuery responsive offcanvas navigation menu</h1>
  
  <p>This is simple offcanvas navigation menu build on HTML, LESS and jQuery. You can use it as a starter offcanvas template for your next project. If you want to see compiled version of LESS just click on <i>"View Compiled"</i> button in CSS section. In CSS there are comments that highlight what's important to include. There is a full tutorial on how to use this offcanvas navigation menu at slicejack.com/blog, just click on button bellow to read full article.</p>

  <a href="http://slicejack.com/simple-html-less-jquery-responsive-offcanvas-navigation-menu/" class="btn" target="_blank">Read more on Slicejack.com</a>
</div><!-- /.page wrap -->

<div class="offcanvas">
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">Blog</a></li>
    <li><a href="#">About us</a></li>
    <li><a href="#">Contact</a></li>
    <li><a href="#">Twitter</a></li>
  </ul>
</div><!-- /.offcanvas -->
              
            
!

CSS

              
                /*
 * Body & Main styles
 */

@primary-color: #ffd200;
@secondary-color: #00174f;

body{ 
  color: #fff;
  background-color: @secondary-color;  
  font-family: 'Open sans', Helvetica, sans-serif;
  
  /* This is !important to include */
  overflow: hidden;
}

h1{
  font-size: 45px;
  color: @primary-color;
}

p, a{
  font-size: 17px;
  line-height: 29px;
  font-weight: 300;
  letter-spacing: 0.5px;
}

.btn{
  background-color: @primary-color;
  color: @secondary-color;
  display: inline-block;
  text-decoration: none;
  padding: 13px 30px;
  margin: 30px 0 0 0;
  border-radius: 3px;
  font-weight: bold;
  .transition;
  
  &:hover{
    background-color: #fff;
  }
}

/*
 * Transitions
 */

.transition{
  /* This is !important to include */
  -webkit-transition: -webkit-transform .2s; 
  -webkit-transition: all 200ms ease-in-out;
  transition: all 200ms ease-in-out;
}

/*
 * Page wrap
 */

.page-wrap{
  padding: 50px 60px;
  overflow: hidden;
  
  /* This is !important to include */
  .transition;
}

.offcanvas-expanded{
  .page-wrap{
    /* This is !important to include */
    -webkit-transform: translateX(320px); 
    -ms-transform: translateX(320px); 
    transform: translateX(320px);
  }
}

/*
 * Offcanvas
 */

.offcanvas{
  /* This is !important to include */
  width: 320px; 
  height: 100%;
  position: fixed;
  top: 0;
  bottom: 0;
  background: #fff; 
  z-index: 5000;
  -webkit-transform: translateX(-320px); 
  -ms-transform: translateX(-320px); 
  transform: translateX(-320px);
  .transition;
  
  ul{
    list-style: none;
    margin: 55px 0 0 0;
    
    li{
      margin: 30px 0;
      
      a{
        color: #000;
        text-decoration: none;
        text-transform: uppercase;
        font-weight: bold;
      }
    }
  }
}

.offcanvas-expanded{
  .offcanvas{
    /* This is !important to include */
    -webkit-transform: translateX(0); 
    -ms-transform: translateX(0); 
    transform: translateX(0);
  }
}

/*
 * Offcanvas toggle
 */

.offcanvas-toggle{
  background-color: transparent;
  border: 0;
  color: #fff;
  
  &:focus{
    outline: none;
  }
  
  &:before{
    content: '\f0c9';
    font-family: 'FontAwesome';
    margin: 0 20px 0 0;
  }
}
              
            
!

JS

              
                // Adding class to body to expand offcanvas from its default state

$('.offcanvas-toggle').on('click', function() {
  $('body').toggleClass('offcanvas-expanded');
});
              
            
!
999px

Console