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 class="offCanvas" data-menu="offcanv_menu_1">
  <ul class="offCanvas_menu">
    <li><a href="#">Home</a></li>
    <li>
      <a href="#">About</a>
      <ul>
        <li><a href="#">Sister Companies to the right to da right</a></li>
        <li><a href="#">More to see</a></li>
        <li>
          <a href="#">Our Team with a longer title here</a>
          <ul>
            <li><a href="#">Angelica</a></li>
            <li><a href="#">John</a></li>
            <li><a href="#">Frank</a></li>
            <li><a href="#">Amy</a></li>
            <li><a href="#">Roberto</a></li>
            <li><a href="#">Matt</a></li>
          </ul>
        </li>
      </ul>
    </li>
    <li><a href="#">Services</a></li>
    <li>
      <a href="#">Products</a>
      <ul>
        <li><a href="#">Product 1</a></li>
        <li><a href="#">Product 2</a></li>
        <li><a href="#">Product 3</a></li>
        <li><a href="#">Product 4</a></li>
        <li><a href="#">Product 5</a></li>
        <li><a href="#">Product 6</a></li>
      </ul>
    </li>
    <li><a href="#">Contact</a></li>
  </ul>
  
  <ul class="offCanvas_menu_social">
    <li><a href="https://facebook.com"><i class="fa fa-facebook"></i></a></li>
    <li><a href="https://twitter.com"><i class="fa fa-twitter"></i></a></li>
    <li><a href="http://instagram.com"><i class="fa fa-instagram"></i></a></li>
  </ul>
</div> <!-- /.offCanvas -->

<div class="offCanvas" data-menu="offcanv_menu_2">  
  I'm a menu from the left hand side.
</div> <!-- /.offCanvas -->

<div class="onCanvas">
  <div id="header">
    <a href="#" id="offcanv_menu_2" style="float:left;"></a>
    <a href="#" class="logo">LOGO</a>
    <ul class="menu">
      <li><a href="#">Home</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Services</a></li>
      <li><a href="#">History</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
    <a href="#" id="offcanv_menu_1"></a>
  </div> <!-- /#header -->

  <div id="content">
    <div class="content_center">
      <h2>Step 1. Copy in the styles and scripts</h2>
      <ul>
        <li>Drop in the CSS (ignoring the 'Unrelated Styles') and JS (put JS at bottom of page)</li>
      </ul>
      <h2>Step 2. Define the On-Canvas Element</h2>
      <ul>
        <li>Wrap the body of your 'on-canvas' (<strong>everything</strong> other than the off-canvas menu) in a <code>&#60;div class="onCanvas"/&#62;</code></li>
      </ul>
      <h2>Step 3. Create the Off-Canvas Element</h2>
      <ul>
        <li>Create an 'off-canvas' element (anything in the off-canvas menu) by using a <code>&#60;div class="offCanvas" data-menu="offcanv_menu_1"/&#62;</code> where the id is unique to this menu</li>
        <li>Add an unordered list with the menu items to create the menu with sub-menus used in this example - <code>&#60;div class="offCanvas_menu"/&#62;</code></li>
      </ul>
      <h2>Step 4. Add a hamburger button to trigger the open/close</h2>
      <ul>
        <li>Create the hamburger menu trigger by a simple <code>&#60;a/&#62;</code> tag with a unique ID that matches the off-canvas data-menu attribute - eg. <code>&#60;a id="offcanv_menu_1"&#62;&#60;/a&#62;</code></li>
      </ul>
      <h2>Step 5. Configuration</h2>
      <ul>
        <li>Use Media Queries to show/hide the trigger button</li>
        <li>Set the position for the menu to slide in by the options.</li>
      </ul>

      <hr />
       <p>At aptent a vestibulum per montes ultricies massa in rhoncus mi in vestibulum vel suspendisse praesent. Diam iaculis vestibulum non vel suspendisse a facilisi curabitur per purus mus est cum a euismod a a condimentum suscipit condimentum nibh mi rutrum mauris. Suscipit vestibulum nascetur imperdiet natoque eros erat rutrum adipiscing neque scelerisque ullamcorper nisi adipiscing mus vivamus nec. Vestibulum a habitasse auctor mollis suspendisse nisi condimentum a imperdiet vestibulum condimentum massa a per suspendisse natoque sed fames mus placerat vestibulum adipiscing augue taciti ridiculus sit inceptos. Vestibulum metus velit potenti placerat condimentum mattis elit per ipsum nibh aliquam praesent elementum a convallis congue posuere adipiscing nisl donec.</p>

      <p>Scelerisque lectus quam natoque netus lacinia augue parturient feugiat habitant venenatis curabitur luctus laoreet morbi consectetur arcu lorem et ad ullamcorper ante dolor hac a hendrerit placerat. Quis parturient condimentum maecenas sem a tempor egestas sociosqu neque lacus dapibus a ad in scelerisque. Iaculis at duis etiam ac class morbi rhoncus placerat ultrices vel ullamcorper est eu nam a scelerisque nascetur. </p>

      <p>At aptent a vestibulum per montes ultricies massa in rhoncus mi in vestibulum vel suspendisse praesent. Diam iaculis vestibulum non vel suspendisse a facilisi curabitur per purus mus est cum a euismod a a condimentum suscipit condimentum nibh mi rutrum mauris. Suscipit vestibulum nascetur imperdiet natoque eros erat rutrum adipiscing neque scelerisque ullamcorper nisi adipiscing mus vivamus nec. Vestibulum a habitasse auctor mollis suspendisse nisi condimentum a imperdiet vestibulum condimentum massa a per suspendisse natoque sed fames mus placerat vestibulum adipiscing augue taciti ridiculus sit inceptos. Vestibulum metus velit potenti placerat condimentum mattis elit per ipsum nibh aliquam praesent elementum a convallis congue posuere adipiscing nisl donec.</p>
    </div>
  </div>
  <div id="footer">&copy; 2015 Company Name</div>
</div> <!-- /.onCanvas -->
            
          
!
            
              /* Unrelated Styles */
/* ============================== */
#content, #footer {
  padding: 10px 10px;
  display: block;
  float: left;
  width: 100%;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.content_center {
  max-width: 900px;
  margin: 0 auto;
  float: none;
}
#header {
  display: block;
  float: left;
  width: 100%;
  background: #FF003C;
}
a.logo {
  width: 25%;
  display: block;
  float: left;
  padding: 20px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  color: #fff;
}
.menu {
  display: none;
  float: left;
  list-style: none;
  width: 75%;
  margin: 0;
  text-align: right;
  padding: 0;
}
.menu li {
  margin: 0;
  padding: 0;
  display: inline-block;
}
.menu li a {
  padding: 20px;
  display: block;
  float: left;
  width: 100%;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  text-align: center;
  color: #fff;
}
@media screen and (max-width:767px) {
  .menu {
    display: none;
  }
}

/*
 * jQuery Off Canvas Menu v1.2
 * https://codepen.io/mcnamee/pen/Wbvoew
 * Copyright (c) 2014 Matt Mcnamee
 *
 * Dual licensed under the MIT and GPL licenses:
 *  https://www.opensource.org/licenses/mit-license.php
 *  http://www.gnu.org/licenses/gpl.html
 */
html, body, .onCanvas {
  background: #1D1F20;
  width: 100%;
}

/* Move Other Items */
.onCanvas {
  width: 100%;
  min-height: 100%;
  position: relative;
  height: 100%;
  float: left;
  z-index: 2;
  -webkit-transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  -webkit-transition-property: -webkit-transform;
  -moz-transition-property: -moz-transform;
  transition-property: transform;
  -webkit-transition-duration: 0.4s;
  -moz-transition-duration: 0.4s;
  transition-duration: 0.4s;
  -webkit-transform: translateX(0);
  -moz-transform: translateX(0);
  -ms-transform: translateX(0);
  -o-transform: translateX(0);
  transform: translateX(0);
}
.overflow_hidden,
.overflow_hidden body,
.overflow_hidden .onCanvas {
  overflow: hidden !important;
  height: 100%;
}
html.offCanvas_open body .onCanvas {
  -webkit-transform: translateX(-260px);
  -moz-transform: translateX(-260px);
  -ms-transform: translateX(-260px);
  -o-transform: translateX(-260px);
  transform: translateX(-260px);
}
html.offCanvas_open body .onCanvas.onCanvas_left {
  -webkit-transform: translateX(260px);
  -moz-transform: translateX(260px);
  -ms-transform: translateX(260px);
  -o-transform: translateX(260px);
  transform: translateX(260px);
}
@media screen and (min-width:365px) {
  html.offCanvas_open body .onCanvas {
    -webkit-transform: translateX(-300px);
    -moz-transform: translateX(-300px);
    -ms-transform: translateX(-300px);
    -o-transform: translateX(-300px);
    transform: translateX(-300px);
  }
  html.offCanvas_open body .onCanvas.onCanvas_left {
    -webkit-transform: translateX(300px);
    -moz-transform: translateX(300px);
    -ms-transform: translateX(300px);
    -o-transform: translateX(300px);
    transform: translateX(300px);
  }
}

/* Trigger / Button */
a.offCanvas_trigger {
  display: block;
  float: right;
  margin: 20px 17px 0 0;
  outline: none;
  width: 30px;
  height: 38px;
}
.offCanvas_trigger.offCanvas_trigger_open .offCanvas_trigger_item {
  background: #fff;
}
.offCanvas_trigger.offCanvas_trigger_open .offCanvas_trigger_item:first-child {
  -moz-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
  -moz-transform-origin: 6px 50%;
  -ms-transform-origin: 6px 50%;
  -webkit-transform-origin: 6px 50%;
  transform-origin: 6px 50%;
}
.offCanvas_trigger.offCanvas_trigger_open .offCanvas_trigger_item:nth-child(2) {
  opacity: 0;
}
.offCanvas_trigger.offCanvas_trigger_open .offCanvas_trigger_item:nth-child(3) {
  -moz-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);
  transform: rotate(-45deg);
  -moz-transform-origin: 1px 50%;
  -ms-transform-origin: 1px 50%;
  -webkit-transform-origin: 1px 50%;
  transform-origin: 1px 50%;
}
.offCanvas_trigger_item {
  -moz-transition: all linear 0.4s;
  -o-transition: all linear 0.4s;
  -webkit-transition: all linear 0.4s;
  transition: all linear 0.4s;
  display: block;
  width: 30px;
  height: 3px;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
  -o-border-radius: 3px;
  -ms-border-radius: 3px;
  border-radius: 3px;
  margin: 0 0 5px;
  background: #fff;
}
@media screen and (max-width:767px) {
  a.offCanvas_trigger {
    display: block;
  }
}

/* offCanvas Menu */
.offCanvas {
  padding: 20px 5px 20px 35px;
  height: 100%;
  overflow-y: hidden;
  visibility: hidden;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1;
  width: 235px;
  background-color: #242e30;
  -webkit-transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  -webkit-transition: -webkit-transform .4s 0s, visibility 0s .4s;
  -moz-transition: -moz-transform .4s 0s, visibility 0s .4s;
  transition: transform .4s 0s, visibility 0s .4s;
  -webkit-transform: translateX(80px);
  -moz-transform: translateX(80px);
  -ms-transform: translateX(80px);
  -o-transform: translateX(80px);
  transform: translateX(80px);
  -webkit-overflow-scrolling: touch;
}
.offCanvas.offCanvas_left {
  left: 0;
  -webkit-transform: translateX(-80px);
  -moz-transform: translateX(-80px);
  -ms-transform: translateX(-80px);
  -o-transform: translateX(-80px);
  transform: translateX(-80px);
}
@media screen and (min-width:365px) {
  .offCanvas {
    width: 275px
  }
}
html.offCanvas_open .offCanvas.offCanvas_menu_open {
  -webkit-transform: translateX(0);
  -moz-transform: translateX(0);
  -ms-transform: translateX(0);
  -o-transform: translateX(0);
  transform: translateX(0);
  visibility: visible;
  -webkit-transition: -webkit-transform .4s 0s, visibility 0s 0s;
  -moz-transition: -moz-transform .4s 0s, visibility 0s 0s;
  transition: transform .4s 0s, visibility 0s 0s;
  overflow-y: scroll;
}
ul.offCanvas_menu {
  width: 100%;
  position: relative;
  padding: 0;
  margin: 0;
  display: block;
}
ul.offCanvas_menu, ul.offCanvas_menu ul {
  -webkit-transform: translateZ(0);
  list-style: none;
  float: left;
  width: 100%;
  display: block;
  margin: 0 0 20px;
  padding: 0;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  -o-box-sizing: border-box;
  -ms-box-sizing: border-box;
  box-sizing: border-box;
}
ul.offCanvas_menu ul {
  padding: 0 0 15px 20px;
  margin: 0;
  display: none;
}
ul.offCanvas_menu li {
  list-style: none;
  display: block;
  margin: 0;
  padding: 0;
  width: 100%;
  float: left;
  cursor: pointer;
  position: relative;
}
ul.offCanvas_menu li a {
  display: block;
  float: left;
  width: 75%;
  padding: 7px 0;
  font-size: 16px;
  color: #ddd;
  text-overflow : ellipsis;
  white-space   : nowrap;
  overflow      : hidden;
}
ul.offCanvas_menu > li > a {
  text-transform: uppercase;
  font-size: 18px;
}
ul.offCanvas_menu li a:hover {
  color: #fff;
}

/* offCanvas Sub-Menu Indicator */
ul.offCanvas_menu li .offCanvas_menu_has_children_indicator {
  display: block;
  float: left;
  width: 25%;
  height: 20px;
  position: absolute;
  right: 0;
  top: 8px;
  text-align: center;
}
ul.offCanvas_menu li > .offCanvas_menu_has_children_indicator svg {
  fill: #fff;
  width: 11px;
  height: 11px;
  -webkit-transform: rotate(0deg);
  -moz-transform: rotate(0deg);
  -ms-transform: rotate(0deg);
  -o-transform: rotate(0deg);
  transform: rotate(0deg);
  -webkit-transition: -webkit-transform ease 0.2s;
  -moz-transition: -moz-transform ease 0.2s;
  -ms-transition: -ms-transform ease 0.2s;
  -o-transition: -o-transform ease 0.2s;
  transition: transform ease 0.2s;
}
ul.offCanvas_menu li.offCanvas_menu_sub_open > .offCanvas_menu_has_children_indicator svg {
  -webkit-transform: rotate(180deg);
  -moz-transform: rotate(180deg);
  -ms-transform: rotate(180deg);
  -o-transform: rotate(180deg);
  transform: rotate(180deg);
}

/* Social Icons */
ul.offCanvas_menu_social,
ul.offCanvas_menu_social li {
  list-style: none;
  text-align: center;
  margin: 0;
  padding: 0;
}
ul.offCanvas_menu_social {
  width: 90%;
  float: left;
  margin-bottom: 80px;
}
ul.offCanvas_menu_social li {
  display: inline-block;
  padding: 0 8px;
}
ul.offCanvas_menu_social li a {
  color: #777;
  font-size: 28px;
}
ul.offCanvas_menu_social li a:hover {
  color: #999;
}
            
          
!
            
              /*
 * jQuery Off Canvas Menu v1.2
 * https://codepen.io/mcnamee/pen/Wbvoew
 * Copyright (c) 2014 Matt Mcnamee
 *
 * Dual licensed under the MIT and GPL licenses:
 *  https://www.opensource.org/licenses/mit-license.php
 *  http://www.gnu.org/licenses/gpl.html
 */
(function ( $ ) {
  $.fn.offCanvasMenu = function( options ) {

    /* Defaults */
    var settings = $.extend({
      menu_ul: ".offCanvas_menu",
      position: "right"
    }, options ),
       this_btn = this,
    	 this_btn_id = this.attr('id'),
        respective_menu = $("div[data-menu='" + this_btn_id +"']");

    /* Set the side which it'll slide in */
    /* ========================================== */
    if( settings.position == "left" ) {
      // $('.onCanvas').addClass('onCanvas_left');
      respective_menu.addClass('offCanvas_left');
    }
    
    /* Style the hamburger menu */
    /* ========================================== */
    this.html('<span class="offCanvas_trigger_item"></span><span class="offCanvas_trigger_item"></span><span class="offCanvas_trigger_item"></span>');
    this.addClass('offCanvas_trigger');
    
    /* Open/Close Menu */
    /* ========================================== */
    $('html').on('click', '#' + this_btn_id, function(e){
      e.preventDefault();
      
      if( settings.position == "left" ) {
      	$('.onCanvas').addClass('onCanvas_left');
      } else {
        $('.onCanvas').removeClass('onCanvas_left');
      }

      $('html').toggleClass('offCanvas_open').one('otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
         /* Wait for the transitions to end before giving body overflow:hidden */
        $('html').toggleClass('overflow_hidden');
      });

       respective_menu.toggleClass('offCanvas_menu_open');

       /* Check if transitions are not supported - eg. IE9 */
      if( $('html').hasClass('no-csstransitions') ) {
        $('html').toggleClass('overflow_hidden');
      }

       /* Change icon when animation is complete */
       setTimeout(function() {
        this_btn.toggleClass('offCanvas_trigger_open');
       }, 200);
      
      return false;
    });

    /* Accordion in offCanvas menu */
    /* ========================================== */
    /* Add class to all li's w/ ul's */
    $( settings.menu_ul + ' li').each(function(){
      if( $(this).has('ul').length ) {
        $(this).addClass('offCanvas_menu_has_children');
        $(this).append('<span class="offCanvas_menu_has_children_indicator"><svg><polygon points="0,2 10,2 5,10"/></svg></span>');
      }
    });

    /* Drop Downs */
    $('.offCanvas_menu_has_children_indicator').on('click', function(e){
      e.preventDefault();
      $(this).parent('li').toggleClass('offCanvas_menu_sub_open').children('ul').slideToggle(400);

      return false;
    });
  }
}( jQuery ));

/*
	Options: {
     menu_ul: (str)  The accordion-like ul within the menu,
     position: (str) The side to which menu slides in - either left or right (default: right)
   }
*/
$('#offcanv_menu_1').offCanvasMenu();
$('#offcanv_menu_2').offCanvasMenu({'position':'left'});
            
          
!
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