LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code
Toggle Nav

Off Canvas Menu Tutorial

Basic demo showing how to easily implement an Off Canvas Menu by scotch.io.

CSS
/*
* 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;
}
JS
/*
* 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');
}
Host Instantly Drag and Drop Website Builder

 

Term
Mon, 11/27/2017 - 22:10

Related Codes

Pen ID
Pen ID
Pen ID