Minimal Off-canvas Navigation with jQuery and CSS3

Minimal Off-canvas Navigation with jQuery and CSS3
File Size: 6.29 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT

A minimalist jQuery & CSS3 implementation of mobile-friendly navigation that automatically collapses a regular navigation into an off-canvas menu on smaller viewports.

How to use it:

1. Load jQuery library and other necessary resources in your Html page.

<link href="//" rel="stylesheet">
<link href="//" rel="stylesheet">
<script src="//"></script>

2. Create a mobile friendly navigation menu for your webpage following the html structure like this:

<div id="site-wrapper">
  <div id="site-canvas">
    <div id="site-menu">
      <ul class="menu-items">
    <div class="row" id="navbar">
      <div class="col-xs-12">
        <div class="col-xs-3 col-md-2" id="brand"> BRAND </div>
        <div class="visible-lg">
          <div class="col-md-10">
            <ul class="items">
              <li class="item">Home</li>
              <li class="item">About</li>
              <li class="item">Contact</li>
        <div class="hidden-lg"> <a href="#" class="toggle-nav"> <i class="fa fa-bars fa-2x"></i> </a> </div>
    <div class="container" id="page-content">
      Main Content goes here...

3. The basic styles for the off-canvas menu.

#site-wrapper {
  position: relative;
  overflow: hidden;
  width: 100%;

#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;

.show-nav #site-canvas {
  -webkit-transform: translateX(-200px);
  transform: translateX(-200px);
  -webkit-transform: translate3d(-200px, 0, 0);
  transform: translate3d(-200px, 0, 0);

#site-menu {
  width: 200px;
  height: 1000px;
  position: absolute;
  top: 0;
  right: -200px;
  background: #F5766E;
  padding-top: 28px;
  color: white;
  text-align: center;

#site-menu ul {
  text-align: center;
  list-style-type: none;
  display: inline-block;
  font-family: "roboto";
  font-size: 20px;

#site-menu ul li { padding: 5px; }

4. The core JavaScript function.

function toggleNav() {
  if ($('#site-wrapper').hasClass('show-nav')) {
  } else {

5. Toggle the off-canvas navigation on click.

$(function() {
  $('.toggle-nav').click(function() {

This awesome jQuery plugin is developed by himmel. For more Advanced Usages, please check the demo page or visit the official website.