Skip to content

Instantly share code, notes, and snippets.

@arulprabakaran
Last active July 27, 2017 12:17
Show Gist options
  • Save arulprabakaran/d5255c38511981029fdb to your computer and use it in GitHub Desktop.
Save arulprabakaran/d5255c38511981029fdb to your computer and use it in GitHub Desktop.
Off Canvas Menu
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="ie6 oldie" lang='en' dir='ltr'> <![endif]-->
<!--[if IE 7]> <html class="ie7 oldie" lang='en' dir='ltr'> <![endif]-->
<!--[if IE 8]> <html class="ie8 oldie" lang='en' dir='ltr'> <![endif]-->
<!--[if gt IE 8]><!-->
<html lang='en' dir='ltr'>
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Off Canvas Menu</title>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
body.show-nav {
overflow: hidden;
}
.wrapper {
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;
}
.mobile-menu {
width: 300px;
height: 100%;
position: absolute;
top: 0;
left: -300px;
background: #4a5b6c;
padding: 15px;
z-index: 9998;
padding-top: 30px;
}
.show-nav .wrapper {
-webkit-transform: translateX(300px);
transform: translateX(300px);
-webkit-transform: translate3d(300px, 0, 0);
transform: translate3d(300px, 0, 0);
}
.navbar-toggle .icon-bar {
background: #555;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="mobile-menu visible-xs">
<a href="#" class="mobile-menu-close navbar-toggle">X</a>
<ul class="main-nav">
<li><a href="/">Home</a></li>
<li><a href="/about-us/">About Us</a></li>
<li><a href="/investor-relations/">Investor Relations</a></li>
<li><a href="/developments/">Developments</a></li>
<li><a href="/media/">Media</a></li>
<li><a href="/careers/">Careers</a></li>
<li><a href="/contact-us/">Contact Us</a></li>
</ul>
</div>
<div class="main-wrapper">
<button class="navbar-toggle">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script>
$('.navbar-toggle').click(function(e) {
e.preventDefault();
if ($('body').hasClass('show-nav')) {
$('body').removeClass('show-nav');
} else {
$('body').addClass('show-nav');
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment