Fullpage + Bootstrap 3 | Sidebar

by Dhanck

HTML

<script src="http://alvarotrigo.com/fullPage/jquery.fullPage.min.js"></script>
<link rel="stylesheet" href="http://alvarotrigo.com/fullPage/jquery.fullPage.css">
<div id="wrapper">
  <!-- Sidebar -->
  <div id="sidebar-wrapper">
    <ul class="sidebar-nav nav-pills nav-stacked" id="menu">

      <li class="active">
        <a href="#"><span class="fa-stack fa-lg pull-left"><i class="fa fa-dashboard fa-stack-1x "></i></span> Dashboard</a>
        <ul class="nav-pills nav-stacked" style="list-style-type:none;">
          <li><a href="#firstPage">link1</a></li>
          <li><a href="#secondPage">link2</a></li>
        </ul>
      </li>      
    </ul>
  </div>
	</div>
  <!-- /#sidebar-wrapper -->

  <div class="navbar-collapse" id="bs-example-navbar-collapse-1">
      <div class="active pull-right">
        <button class="navbar-toggle collapse in" data-toggle="collapse" id="menu-toggle-2"> <span class="glyphicon glyphicon-th-large" aria-hidden="true"></span></button>
      </div>
  </div>
  <!-- bs-example-navbar-collapse-1 -->
  <div id="fullpage">
    <div class="section"></div>
    <div class="section"></div>
    <div class="section"></div>
    <div class="section"></div>
  </div>

CSS

/* Toggle Styles */

#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;
  overflow: hidden;
}

#wrapper.toggled {
  padding-left: 250px;
  overflow: scroll;
}
.pull-right {
    position: absolute;
    top: 0px;
    right: 0px;
    z-index: 99;
}
#sidebar-wrapper {
  z-index: 1000;
  position: absolute;
  left: 250px;
  width: 0;
  height: 100%;
  margin-left: -250px;
  overflow-y: auto;
  background: #000;
  -webkit-transition: all 0.5s ease;
  -moz-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  transition: all 0.5s ease;
}

#wrapper.toggled #sidebar-wrapper {
  width: 250px;
}

#page-content-wrapper {
  position: absolute;
  padding: 15px;
  width: 100%;
  overflow-x: hidden;
}

.xyz {
  min-width: 360px;
}

#wrapper.toggled #page-content-wrapper {
  position: relative;
  margin-right: 0px;
}

.fixed-brand {
  width: auto;
}


/* Sidebar Styles */

.sidebar-nav {
  position: absolute;
  top: 0;
  width: 250px;
  margin: 0;
  padding: 0;
  list-style: none;
  margin-top: 2px;
}

.sidebar-nav li {
  text-indent: 15px;
  line-height: 40px;
}

.sidebar-nav li a {
  display: block;
  text-decoration: none;
  color: #999999;
}

.sidebar-nav li a:hover {
  text-decoration: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
  border-left: red 2px solid;
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
  text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
  height: 65px;
  font-size: 18px;
  line-height: 60px;
}

.sidebar-nav > .sidebar-brand a {
  color: #999999;
}

.sidebar-nav > .sidebar-brand a:hover {
  color: #fff;
  background: none;
}

.no-margin {
  margin: 0;
}

@media(min-width:768px) {
  #wrapper {
    padding-left: 0px;
  }
  .fixed-brand {
    width: 250px;
  }
  #wrapper.toggled {
    padding-left: 0;
  }
  #sidebar-wrapper {
    width: 250px;
  }
  #wrapper.toggled #sidebar-wrapper {
    width: 250px;
  }
 ...

JavaScript

$(document).ready(function() {
   $('#fullpage').fullpage({
     sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE', 'whitesmoke', '#ccddff'],
     anchors: ['firstPage', 'secondPage', '3rdPage', '4thpage', 'lastPage'],
     menu: '.sidebar-nav',
     css3: true,
     scrollingSpeed: 1000
   });

   $('#showExamples').click(function(e) {
     e.stopPropagation();
     e.preventDefault();
     $('#examplesList').toggle();
   });

   $('html').click(function() {
     $('#examplesList').hide();
   });
 });
 $("#menu-toggle").click(function(e) {
   e.preventDefault();
   $("#wrapper").toggleClass("toggled");
 });
 $("#menu-toggle-2").click(function(e) {
   e.preventDefault();
   $("#wrapper").toggleClass("toggled-2");
   $('#menu ul').hide();
 });

 function initMenu() {
   $('#menu ul').hide();
   $('#menu ul').children('.current').parent().show();
   //$('#menu ul:first').show();
   $('#menu li a').click(
     function() {
       var checkElement = $(this).next();
       if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
         return false;
       }
       if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
         $('#menu ul:visible').slideUp('normal');
         checkElement.slideDown('normal');
         return false;
       }
     }
   );
 }
 $(document).ready(function() {
   initMenu();
 });