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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div id="sidebar">
  <ul class="menu">
    <li class="menu-global menu-top" onclick="window.open('https://codepen.io/woodwork/', '_blank');">
      <span class="menu-text">More Pens</span>
    </li>
    <li class="menu-global menu-middle">
      <span class="menu-text">Ai Weiwei</span>
    </li>
    <li class="menu-global menu-bottom">
      <span class="menu-text">Bert Heller</span>
    </li>
    <li class="menu-global menu-hidden">
      <span class="menu-text">Gustav Klimt</span>
    </li>
    <li class="menu-global menu-hidden">
      <span class="menu-text">Paul Klee</span>
    </li>
    <li class="menu-global menu-hidden">
      <span class="menu-text">Egon Schiele</span>
    </li>
    <div class="menu-close fa fa-close"></div>
    <div class="click-blocker"></div>
  </ul>
</div>

<div id="page">
  <h1>The same bones as <a href="https://codepen.io/woodwork/pen/BoEGYZ" target="_blank">Version 1...</a></h1>
  <h2>But now with the posibility to have more than three menu items.</h2>
  <p>Currently limited to 10 items. If you need even more add extra colors to the SCSS <code>$menuColor</code> list and make sure your added <code>&lt;li&gt;</code> items classes are set to <code>"menu-global menu-hidden"</code></p>
</div>

<footer id="footer">
  <p id="footer-text"><a href="https://codepen.io/woodwork/pen/BoEGYZ" target="_blank"><b>VERSION 1</b></a></p>
</footer>
              
            
!

CSS

              
                $itemHeight: 50px;

$bgColor: #FF5252;
$bgColor2: #FF1744;

//Currently 10 colors, add more if you have over 10 menu items
$menuColor: #E0F7FA
  #B2EBF2 #80DEEA #4DD0E1
  #26C6DA #00BCD4 #00ACC1 
  #0097A7 #00838F #006064;

$top-font: 'Montserrat', sans-serif;
$mid-font: 'Lato', sans-serif;

@mixin transition($obj, $dur, $del, $obj2, $dur2, $del2){
  -webkit-transition: $obj $dur $del, $obj2 $dur2 $del2;
          transition: $obj $dur $del, $obj2 $dur2 $del2;
}

body {
  background: $bgColor;
  background: linear-gradient(to left, $bgColor 40%, $bgColor2);
  padding: 60px;
  color: #FFF;
  font-family: $mid-font;

  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

h1, h2{
  font-family: $top-font;
  margin: 10px 0;
}

span {
  display: inline-block;
}

ul {
  display: block;
  list-style-type: none;
  text-align: right;
}

a {
  color: #80DEEA;
}
a:hover {
  opacity: 0.6;
}

code {
  color: #000;
  opacity: 0.5;
}

#sidebar{
  position: absolute;
  top: 0; left: 0;
  width: 250px;
  height: 80%;
  margin: 60px 0 0 60px;
}
#page{
    margin-left: 250px;
    max-width:800px; 
}
#footer{
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.2);
}
#footer-text{
  padding-left: 60px;
  opacity:0.6;
}

.menu {
  position: relative;
  margin: 0 20px 0 0;
  padding-left: 1.25em;
  cursor: pointer;
  width: 30px;
  height: 50px;
  text-align: right;
}

/*A simple overlay that registers the menu click*/
/*needed because of e.stopPropagation(); blocking the menu-global click function*/
.click-blocker{
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}

.menu-close {
  font-size: 0em;
  opacity: 0;
  font-weight: bold;
  position: absolute;
  left: 20px;
  top: 0;

  @include transition(all, 0.2s, 0s, null, null, null);
}

.menu-close-visible {
  font-size: 2em;
  opacity: 1;

  @include transition(all, 0.2s, 0.4s, null, null, null);

}

.menu-global {
  position: absolute;
  left: 0;
  height: 10px; 
  width: 100%;
  background-color: #FFF;

  @include transition(all, 0.2s, 0s, null, null, null);
}

.menu-top {
  top: 0;
}
.menu-middle {
  top: 18px;
}
.menu-bottom, .menu-hidden {
  top: 36px;
}

.menu-text{
  color: #000;
  opacity: 0;
  font-size: 0em;
  padding: 10px 0;
  @include transition(all, 0.1s, 0s, null, null, null);
}

.expand {
  box-shadow: rgba(0, 0, 0, 0.1) -2.5px 5px 7.5px, rgba(0, 0, 0, 0.1) 2.5px 5px 7.5px;
  width: 200px;
  height: $itemHeight;
  background: $menuColor(length($menuColor));  //set default as last color
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  @include transition(all, 0.5s, 0s, left, 0.1s, 0s);
}

.expand:hover {
  left: 10px;
  @include transition(all, 0.2s, 0s, null, null, null);
}

.menu-top-expand {
  top: $itemHeight;
  background: nth($menuColor, 1);
  @include transition(all, 0.5s, 0.4s, left, 0.1s, 0s);
}

.menu-middle-expand {
  top: $itemHeight*2;
  background: nth($menuColor, 2);
  @include transition(all, 0.5s, 0.3s, left, 0.1s, 0s);
}

.menu-bottom-expand {
  top: $itemHeight*3;
  background: nth($menuColor, 3);
  @include transition(all, 0.5s, 0.2s, left, 0.1s, 0s);
}

.menu-text-expand{
  opacity: 0.6;
  padding: 10px;
  font-size: 1.3em;
  @include transition(all, 0.2s, 0.7s, font-size, 0.1s, 0s);
}

/******************ADDITIONAL MENU ITEMS*******************/
/***Will inherit transition w/out delay unless overriden***/
@for $i from 1 through length($menuColor) {
   .menu-hidden-expand:nth-child(#{$i}) {
       background: nth($menuColor, $i);
       top: $itemHeight*$i;
   }
}

.menu-hidden-expand:nth-child(4) {
  @include transition(all, 0.5s, 0.1s, left, 0.1s, 0s);
}
.menu-hidden-expand:nth-last-of-type(1) {
  height: $itemHeight*2;
}
/**************END ADDITIONAL MENU ITEMS*******************/
              
            
!

JS

              
                var Menu = {
  el: {
    menu: $('.menu'),
    menuTop: $('.menu-top'),
    menuClose: $('.menu-close'),
    menuMiddle: $('.menu-middle'),
    menuBottom: $('.menu-bottom'),
    menuHidden: $('.menu-hidden'),
    menuText: $('.menu-text')
  },
  
  init: function() {
    Menu.bindUIactions();
  },
  
  bindUIactions: function() {
    Menu.el.menu
        .on(
          'click',
        function(event) {
        Menu.activateMenu(event);
        event.preventDefault();
      }
    );
  },
  
  activateMenu: function() {
    Menu.el.menuTop.toggleClass('menu-top-expand expand');
    Menu.el.menuMiddle.toggleClass('menu-middle-expand expand');
    Menu.el.menuBottom.toggleClass('menu-bottom-expand expand'); 
    Menu.el.menuHidden.toggleClass('menu-hidden-expand expand'); 
    Menu.el.menuText.toggleClass('menu-text-expand');
    Menu.el.menuClose.toggleClass('menu-close-visible');
  }
};
  
  //Stop menu item click closing the menu
  $(".menu .menu-global").click(function(e) {
      e.stopPropagation();
});

Menu.init();
              
            
!
999px

Console