<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div id="wrapper" class="closed">
<div class="overlay"></div>
<!-- Sidebar -->
<nav class="navbar navbar-inverse navbar-fixed-top sidebar-wrapper" role="navigation">
<ul class="nav sidebar-nav">
<li class="sidebar-brand">
<a href="#">
Brand
</a>
</li>
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">About</a>
</li>
<li>
<a href="#">Events</a>
</li>
<li>
<a href="#">Team</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Works <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class="dropdown-header">Dropdown heading</li>
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
<li>
<a href="#">Services</a>
</li>
<li>
<a href="#">Contact</a>
</li>
<li>
<a href="https://twitter.com/maridlcrmn">Follow me</a>
</li>
</ul>
</nav>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<button type="button" class="hamburger">
<span class="hamb-top"></span>
<span class="hamb-middle"></span>
<span class="hamb-bottom"></span>
</button>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<h1>Fancy Toggle Sidebar Navigation</h1>
<p>New revision</p>
<ul>
<li>Uses CSS to toggle wrapper class from open to closed - rest of work is done in CSS</li>
<li>Includes breakpoints to show menu all the time on larger screens</li>
<li>All CSS classes are only applied to things within #wrapper</li>
</ul>
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<!-- /#wrapper -->
body {
position: relative;
overflow-x: hidden;
}
body,
html { height: 100%;}
.nav .open > a,
.nav .open > a:hover,
.nav .open > a:focus {background-color: transparent;}
/*-------------------------------*/
/* Wrappers */
/*-------------------------------*/
@media(max-width:991px){
#wrapper.closed .sidebar-wrapper { width: 0 ; }
#wrapper.closed #page-content-wrapper {
width: 100%;
padding-top: 70px;
}
#wrapper.open .sidebar-wrapper { width: 220px; }
#wrapper.open { padding-left: 220px; }
#wrapper.open #page-content-wrapper {
position: absolute;
margin-right: -220px;
}
}
@media(min-width:992px){
#wrapper .sidebar-wrapper { width: 220px; }
#wrapper { padding-left: 220px; }
#wrapper .container { margin-left : 220px ; }
}
#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper .sidebar-wrapper {
z-index: 1000;
left: 220px;
height: 100%;
margin-left: -220px;
overflow-y: auto;
overflow-x: hidden;
background: #1a1a1a;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper .sidebar-wrapper::-webkit-scrollbar { display: none; }
/*-------------------------------*/
/* Sidebar nav styles */
/*-------------------------------*/
#wrapper .sidebar-nav {
position: absolute;
top: 0;
width: 220px;
margin: 0;
padding: 0;
list-style: none;
}
#wrapper .sidebar-nav li {
position: relative;
line-height: 20px;
display: inline-block;
width: 100%;
}
#wrapper .sidebar-nav li:before {
content: '';
position: absolute;
top: 0;
left: 0;
z-index: -1;
height: 100%;
width: 3px;
background-color: #1c1c1c;
-webkit-transition: width .2s ease-in;
-moz-transition: width .2s ease-in;
-ms-transition: width .2s ease-in;
transition: width .2s ease-in;
}
#wrapper .sidebar-nav li:first-child a {
color: #fff;
background-color: #1a1a1a;
}
#wrapper .sidebar-nav li:nth-child(2):before { background-color: #ec1b5a; }
#wrapper .sidebar-nav li:nth-child(3):before { background-color: #79aefe; }
#wrapper .sidebar-nav li:nth-child(4):before { background-color: #314190; }
#wrapper .sidebar-nav li:nth-child(5):before { background-color: #279636; }
#wrapper .sidebar-nav li:nth-child(6):before { background-color: #7d5d81; }
#wrapper .sidebar-nav li:nth-child(7):before { background-color: #ead24c; }
#wrapper .sidebar-nav li:nth-child(8):before { background-color: #2d2366; }
#wrapper .sidebar-nav li:nth-child(9):before { background-color: #35acdf; }
#wrapper .sidebar-nav li:hover:before,
#wrapper .sidebar-nav li.open:hover:before {
width: 100%;
-webkit-transition: width .2s ease-in;
-moz-transition: width .2s ease-in;
-ms-transition: width .2s ease-in;
transition: width .2s ease-in;
}
#wrapper .sidebar-nav li a {
display: block;
color: #ddd;
text-decoration: none;
padding: 10px 15px 10px 30px;
}
#wrapper .sidebar-nav li a:hover,
#wrapper .sidebar-nav li a:active,
#wrapper .sidebar-nav li a:focus,
#wrapper .sidebar-nav li.open a:hover,
#wrapper .sidebar-nav li.open a:active,
#wrapper .sidebar-nav li.open a:focus{
color: #fff;
text-decoration: none;
background-color: transparent;
}
#wrapper .sidebar-nav > .sidebar-brand {
height: 65px;
font-size: 20px;
line-height: 44px;
}
#wrapper .sidebar-nav .dropdown-menu {
position: relative;
width: 100%;
padding: 0;
margin: 0;
border-radius: 0;
border: none;
background-color: #222;
box-shadow: none;
}
/*-------------------------------*/
/* Hamburger-Cross */
/*-------------------------------*/
@media(max-width:991px){
#wrapper .hamburger {
position: fixed;
top: 20px;
z-index: 999;
display: block;
width: 32px;
height: 32px;
margin-left: 15px;
background: transparent;
border: none;
}
#wrapper .hamburger:hover,
#wrapper .hamburger:focus,
#wrapper .hamburger:active {
outline: none;
}
#wrapper.closed .hamburger:before {
content: '';
display: block;
width: 100px;
font-size: 14px;
color: #fff;
line-height: 32px;
text-align: center;
opacity: 0;
-webkit-transform: translate3d(0,0,0);
-webkit-transition: all .35s ease-in-out;
}
#wrapper.closed .hamburger:hover:before {
opacity: 1;
display: block;
-webkit-transform: translate3d(-100px,0,0);
-webkit-transition: all .35s ease-in-out;
}
#wrapper .hamburger span
{
position: absolute;
left: 0;
height: 4px;
width: 100%;
}
#wrapper.closed .hamburger span { background-color: #1a1a1a; }
#wrapper.closed .hamburger .hamb-top {
top: 5px;
-webkit-transition: all .35s ease-in-out;
}
#wrapper.closed .hamburger .hamb-middle {
top: 50%;
margin-top: -2px;
}
#wrapper.closed .hamburger .hamb-bottom {
bottom: 5px;
-webkit-transition: all .35s ease-in-out;
}
#wrapper.closed .hamburger:hover .hamb-top {
top: 0;
-webkit-transition: all .35s ease-in-out;
}
#wrapper.closed .hamburger:hover .hamb-bottom {
bottom: 0;
-webkit-transition: all .35s ease-in-out;
}
#wrapper.open .hamburger span { background-color: #1a1a1a; }
#wrapper.open .hamburger .hamb-top,
#wrapper.open .hamburger .hamb-bottom {
top: 50%;
margin-top: -2px;
}
#wrapper.open .hamburger .hamb-top {
-webkit-transform: rotate(45deg);
-webkit-transition: -webkit-transform .2s cubic-bezier(.73,1,.28,.08);
}
#wrapper.open .hamburger .hamb-middle { display: none; }
#wrapper.open .hamburger .hamb-bottom {
-webkit-transform: rotate(-45deg);
-webkit-transition: -webkit-transform .2s cubic-bezier(.73,1,.28,.08);
}
#wrapper.open .hamburger:before {
content: '';
display: block;
width: 100px;
font-size: 14px;
color: #fff;
line-height: 32px;
text-align: center;
opacity: 0;
-webkit-transform: translate3d(0,0,0);
-webkit-transition: all .35s ease-in-out;
}
#wrapper.open .hamburger:hover:before {
opacity: 1;
display: block;
-webkit-transform: translate3d(-100px,0,0);
-webkit-transition: all .35s ease-in-out;
}
}
@media(min-width:992px){
#wrapper .hamburger { display : none ; }
}
/*-------------------------------*/
/* Overlay */
/*-------------------------------*/
@media(max-width:991px){
#wrapper.closed .overlay { display : none ; }
#wrapper.open .overlay { display : block ; }
}
@media(min-width:992px){
#wrapper .overlay { display : none ; }
}
#wrapper .overlay {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color : rgb(250,250,250) ;
background-color: rgba(250,250,250,.8);
z-index: 1;
}
$(document).ready(function () {
$('.hamburger').click(function () {
$('#wrapper').toggleClass('open');
$('#wrapper').toggleClass('closed');
});
});