123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <template id="hamburger-menu-template">
  <style>
   .hamburger-button {
      position: absolute;
      left: 5px;
      top: 5px;
      z-index: 101;
      padding: 2px;
      width: 32px;
      height: 32px;
      -webkit-border-radius: 5px;
      -webkit-background-clip: padding-box;
      -moz-border-radius: 5px;
      -moz-background-clip: padding;
      border-radius: 5px;
      background-clip: padding-box;
    }
    .hamburger-button:hover .hamburger-line {
      background-color: #2b134a;
    }
    .hamburger-button .hamburger-line {
      pointer-events: none;
      -webkit-border-radius: 2px;
      -webkit-background-clip: padding-box;
      -moz-border-radius: 2px;
      -moz-background-clip: padding;
      border-radius: 2px;
      background-clip: padding-box;
      background-color: #400090;
      height: 4px;
      width: 80%;
      margin: 16% 10%;
    }
    .hamburger-flyout {
      position: absolute;
      -webkit-transition: left 0.3s;
      /* For Safari 3.1 to 6.0 */
      transition: left 0.3s;
      top: 0px;
      left: -200px;
      bottom: 0px;
      width: 200px;
      z-index: 100;
      overflow: hidden;
      background: #400090;
      -webkit-box-shadow: inset -10px 0px 5px -5px rgba(0, 0, 0, 0.4);
      -moz-box-shadow: inset -10px 0px 5px -5px rgba(0, 0, 0, 0.4);
      box-shadow: inset -10px 0px 5px -5px rgba(0, 0, 0, 0.4);
    }
    .hamburger-flyout .hamburger-menu-title {
      color: #fff;
      font-size: 24px;
      margin-top: 13px;
      margin-bottom: 15px;
      margin-left: 5px;
      margin-right: 10px;
      padding-left: 47px;
      padding-bottom: 10px;
      border-bottom: 1px solid #fff;
    }
    .hamburger-flyout .hamburger-menu-item {
      color: #ddd;
      padding: 15px 10px;
      display: block;
      text-decoration: none;
    }
    :host(.open) .hamburger-button .hamburger-line{
      background-color: #fff;
    }
    :host(.open) .hamburger-flyout{
      left: 0;
    }
    ::content hb-menu-item {
      background-color: red !important;  
    }
  </style>
  <div class="hamburger-button">
    <div class="hamburger-line"></div>
    <div class="hamburger-line"></div>
    <div class="hamburger-line"></div>
  </div>

  <div class="hamburger-flyout">
      <div class="hamburger-menu-title">
        MENU TITLE
      </div>
      <content></content>
     
  </div>
</template>

<template id="hb-menu-item-template">
  <style>
  .hamburger-menu-item-caption {
    font-size: 0.7em;
    color: #777777;
  }
  a {
     color: #ddd;
      padding: 15px 10px;
      display: block;
      text-decoration: none;
  }
  a:hover {
    -webkit-transition: background-color 0.2s;
    /* For Safari 3.1 to 6.0 */
    transition: background-color 0.2s;
    background-color: #2b134a;
    -webkit-box-shadow: inset -10px 0px 5px -5px rgba(0, 0, 0, 0.4);
    -moz-box-shadow: inset -10px 0px 5px -5px rgba(0, 0, 0, 0.4);
    box-shadow: inset -10px 0px 5px -5px rgba(0, 0, 0, 0.4);
  }
  </style>
  <a href="#abc">
    <content></content>
    <div class="hamburger-menu-item-caption"></div>
  </a>
</template>

<hamburger-menu title="My Menu">
  <hb-menu-item href="#abc"
                caption="Better get on these soon">
    Serious Bugs
  </hb-menu-item>
  <hb-menu-item href="#def"
                caption="Oh %#@$!">
    Really Serious Bugs
  </hb-menu-item>
</hamburger-menu>


            
          
!
            
              @import "lesshat";

* {
  font-family: 'Helvetica';
}

            
          
!
            
              (function () {
  'use strict';
  
	// Our templates
  var hamburgerMenuTmpl = document.querySelector('#hamburger-menu-template');
  var hamburgerMenuItemTmpl = document.querySelector('#hb-menu-item-template');
  
  // Register the menu
  document.registerElement('hamburger-menu', {
    prototype: Object.create(HTMLElement.prototype, {
      createdCallback: {
        value: function () {
          // Install the template onto the shadow root
          var content = document.importNode(hamburgerMenuTmpl.content, true);
          this.rootElem = this.createShadowRoot();
          this.rootElem.appendChild(content);
          
          // Listen to the hamburger button for clicks
          this.buttonClickListener = function (evt) {
            let menuCssClass = this.getAttribute('class') || "";
            this.setAttribute('class', menuCssClass.indexOf('open') >= 0 ? menuCssClass.replace('open', '') : (menuCssClass + ' open'));
          }.bind(this);
          
          // Hook up click listener
          this.rootElem.querySelector('.hamburger-button').addEventListener('click', this.buttonClickListener);
          // Set title
          this.rootElem.querySelector('.hamburger-flyout .hamburger-menu-title').innerHTML = this.title;
        }
      }
    })
  });

  document.registerElement('hb-menu-item', {
    prototype: Object.create(HTMLElement.prototype, {
      createdCallback: {
        value: function () {
          // Install template
          var content = document.importNode(hamburgerMenuItemTmpl.content, true);
          this.rootElem = this.createShadowRoot();
          this.rootElem.appendChild(content);
          
          // Pass href attribute to link
          this.rootElem.querySelector('a').setAttribute('href', this.getAttribute('href'));
          // Set caption
          this.rootElem.querySelector('.hamburger-menu-item-caption').innerHTML = this.getAttribute('caption');
        }
      }
    })
	});
}());
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console