Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- background image from unsplash.com -->

<div class="menu-icon">
  <span class="menu-bar"></span>
</div>


<nav class="main-menu">
  <div class="user-info">
    <div class="user__avatar">
      <span class="fa-stack fa-lg">
          <i class="fa fa-circle fa-stack-2x"></i>
          <i class="fa fa-user fa-stack-1x"></i>
        </span>
    </div>
    <div class="user__username">
      Guest
    </div>
    <div class="user__status">
      Not logged in
    </div>
  </div>

  <div class="main-menu__nav">
    <h4>Navigation</h4>
    <ul class="main-menu__navigation">
      <li><a href="#"><i class="fa fa-home"></i> Homepage</a></li>
      <li class="sub-menu-trigger"><a href="#"><i class="fa fa-arrow-circle-o-right"></i> Products</a>
        <ul class="navigation__sub-menu">
          <li><a href="#">Example Sub Item</a></li>
          <li><a href="#">Example Sub Item</a></li>
        </ul>
      </li>
      <li><a href="#"><i class="fa fa-question"></i> About Us</a></li>
      <li><a href="#"><i class="fa fa-pencil"></i> Blog</a></li>
      <li><a href="#"><i class="fa fa-newspaper-o"></i> Knowledgebase</a></li>
      <li><a href="#"><i class="fa fa-comments-o"></i> Support forums</a></li>

      <li>
        <h4>Accounts</h4></li>
      <li><a href="#"><i class="fa fa-user"></i> Register</a></li>
      <li><a href="#"><i class="fa fa-lock"></i> Login</a></li>

      <li>
        <h4>Search</h4></li>
      <li class="main-menu__search">
        <input type="search" class="main-menu__search" placeholder="Example...">
        <i class="fa fa-search"></i>
      </li>
    </ul>
  </div>
</nav>

<section class="container">
  <h1>Menu Concept</h1>
</section>
              
            
!

CSS

              
                /* Vars */
$grey200: #EEEEEE;
$grey400: #BDBDBD;
$grey600: #757575;
$grey800: #424242;
$blue500: #2196F3;
$blueGrey700: #455A64;
$white: #fff;
$red500: #F44336;

$body-font-stack: Tahoma, Geneva, sans-serif;
$global-transition-timing: .3s;

/* Reset */

a {
  color: inherit;
  text-decoration: none;
  transition: $global-transition-timing;
}
   
nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

img {
  max-width: 100%;
  height: auto;
}

* {
  box-sizing: border-box;
  transform: translate3d(0);
}

// had to reset the normalize
input[type=search] {
  box-sizing: border-box;
}

/* Main Styles  */
html {
  font-size: 16px;
}

body {
  background: url(https://images.unsplash.com/photo-1444927714506-8492d94b4e3d?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=067f0b097deff88a789e125210406ffe) center center no-repeat;
  background-size: cover;
  color: $grey400;
  font-family: $body-font-stack;
  font-size: 1rem;
  line-height: 1.4;
  height: 100%;
  height: 100vh;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

h1 {
  color: $white;
  font-size: 4rem
}


/* Menu Toggle */
.menu-icon {
  background: $grey400;
  width: 50px;
  height: 50px;
  margin: 0 0 0 auto;
  position: relative;
  cursor: pointer;
  transition: background $global-transition-timing;
}

.menu-bar {
  cursor: pointer;
  border-radius: 1px;
  height: 2px;
  width: 35px;
  background: white;
  position: absolute;
  left: 15%;
  top: 50%;
  display: block;
  transition: all $global-transition-timing;
  
  &.menu-bar::before,
  &.menu-bar::after {
    @extend .menu-bar;
    content: '';
  }
  
  &::before {
    left: 0;
    top: -10px;
  }
  
  &::after {
    left: 0;
    top: 10px;
  }
}


.menu-icon.active {
  background: $grey800;
  
  & span {
    background: transparent;
  }
  
  & .menu-bar {

    &::before, &::after {
      top: 0;
    }
    
    &::before {
      transform: rotate(135deg);
    }
    
    &::after {
      transform: rotate(-135deg);
    }
  }
}

/* Main Menu */
.user-info {
  background: $grey600;
  padding: 1rem;
}

.user__username, .user__avatar {
  font-weight: 300;
}

.user__avatar {
  float: left;
  margin-right: 1rem;
  & .fa-user {
    color: $grey600;
  }
}

.user__status {
  font-size: 0.7rem;
}

.main-menu {
  position: fixed;
  top: 0;
  left: -250px;
  bottom: 0;
  width: 250px;
  background: $grey800;
  opacity: 0;
  overflow: scroll;
  -webkit-overflow-scrolling: touch;
  transition: all $global-transition-timing;
  z-index: 1000;
  &.active {
    left: 0;
    opacity: 1;
    & li {
      opacity: 1;
      transform: translate(0);
    }
  }
  & li {
    opacity: 0;
    transform: translate(-20%,0);
  }
}

/* transition delay for menu */
@for $i from 1 through 12 {
  .main-menu.active li:nth-child(#{$i}) {
    transition-delay: 0.25 * $i + s;
  }
}

.main-menu__nav {
  & h4 {
    color: $white;
    letter-spacing: 2px;
    margin: 1rem 0.4rem;
    font-size: 1rem;
    text-transform: uppercase;
  }
  & i {
    margin-right: 1rem;
  }
}

.main-menu__navigation > li {
  transition: $global-transition-timing;
  & a {
    display: block;
    border-left: 1px solid transparent;
    font-weight: 300;
    letter-spacing: 2px;
    padding: 0.5rem;
  }
  & a:hover {
    background: $blueGrey700;
    color: $white;
    border-color: $blue500;
    text-decoration: none;
  }

  & .navigation__sub-menu {
    display: none;
    font-size: 0.8rem;
    margin-left: 2rem;
    margin-top: 0.5rem;
  }
}

/* Search */
.main-menu__search {
  position: relative;
  padding: 1rem;
  & input {
    width: 100%;
    -moz-appearance: none;
    -webkit-appearance: none;
    border: 1px solid transparent;
    border-radius: 0;
    outline: 0;
    box-shadow: 0;
    background: $blueGrey700;
    padding: 1rem;
    padding-left: 3rem;
    transition: $global-transition-timing;
    &:focus {
      border-color: $blue500;
    }
  }
  & i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translate(100%,-50%);
  }
}
              
            
!

JS

              
                $('.menu-icon').on('click', function() {
  $(this).toggleClass("active");
  $('.main-menu').toggleClass("active").animate({
    scrollTop: 0
  });
  $('.navigation__sub-menu').slideUp();
});

$('.sub-menu-trigger').click(function() {
  $('.navigation__sub-menu').slideToggle(300);
});

$('html').on('click', function(e) {
  if (!$('.menu-icon').is(e.target) && $('.main-menu').has(e.target).length === 0) {
    $('.menu-icon').removeClass('active');
    $('.main-menu').removeClass('active');
  }
});
              
            
!
999px

Console