Pure JavaScript/CSS Sliding Drawer Menu – bpenDrawer

Category: Javascript , Menu & Navigation | February 2, 2015
Author:bitpen
Views Total:8,429 views
Official Page:Go to website
Last Update:February 2, 2015
License:MIT

Preview:

Pure JavaScript/CSS Sliding Drawer Menu – bpenDrawer

Description:

A pure JS/CSS based mobile drawer menu that slides out from the edge of your screen when toggled on, similar to the off-canvas navigation menu you seen on some mobile apps.

How to use it:

Load the bpen.drawer.js script in your document.

<script src="js/bpen.drawer.js">

Create an empty DIV element for the mobile drawer menu.

<div id="mainMenu"></div>

Add items to the menu and place the menu on the right hand side of your document.

var drawer;
  window.addEventListener("load", function(){
    drawer = bpen.drawer("mainMenu",{
      Items : [{
        Text : "home",
        Url : "index.html"
        },{
        Text: "contact",
        Url : "contact.html"
        }
      ],
      Anchor : 'right'
    });
  },false);

The basic CSS styles for the mobile drawer menu. Feel free to modify & override them to make your own styles.

.bpen-drawer {
  position: fixed;
  top: 0px;
  height: 100%;
  width: 225px;
  background-color: #34BC9D;
  z-index: 1000;
  padding: 0 10px;
  transition: 0.5s ease;
}
.bpen-drawer-left { left: -245px; }
.bpen-drawer-right { right: -245px; }
.bpen-drawer-left.expanded { left: 0px; }
.bpen-drawer-right.expanded { right: 0px; }
.bpen-toggle-pad {
  position: absolute;
  top: 0px;
  width: 25px;
  height: 100%;
  color: #fff;
  text-align: center;
  cursor: pointer;
  background: url(../img/icon-menu.svg) no-repeat center center;
  background-size: 25px 25px;
  -webkit-transition: 3s ease;
  -moz-transition: 3s ease;
  -o-transition: 3s ease;
  -ms-transition: 3s ease;
  transition: 0.5s ease;
}
.bpen-toggle-pad-left {
  right: -30px;
  text-align: center;
}
.bpen-toggle-pad-right {
  left : -30px;
  text-align: center;
}
.bpen-toggle-pad-left.expanded { right: 0px; }
.bpen-toggle-pad-right.expanded { left: 0px; }
.bpen-drawer-header {
  position: relative;
  height: 40px;
  width: 100%;
  top: 0px;
  left: 0px;
}
.bpen-drawer-items {
  list-style-type: none;
  padding-left: 0px;
  width: 100%;
  margin-top: 0px;
}
.bpen-drawer-items li {
  padding: 7px 0px 7px 0px;
  width: 100%;
  margin: -1px 0px 0px 0px;
  border-top: 1px solid #46CFB0;
  border-bottom: 1px solid #46CFB0;
  cursor: pointer;
  font-size: 1.5em;
}
.bpen-drawer-items li a {
  display: block;
  text-decoration: none;
  font-weight: bold;
  color : #fff;
  padding-left: 10px;
  width: 100%;
}

You Might Be Interested In:


Leave a Reply