Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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 class="header">
  <header>
    <div class="header__inner">
      <p class="header__title"><a href="http://glatchdesign.com/">Glatch</a></p>
      <p class="header__menu"><a href="#" id="js-header__menu">MENU</a></p>
    </div>
    <!--
        .header__naviにposition: fixedを指定する。
    -->
    <div class="header__navi" id="js-header__navi">
      <p class="header__navi__close"><a href="#" id="js-header__navi__close">×</a></p>
      <!-- 
          .header__navi直下でスクロールさせる為のdiv要素(.header__navi__inner)を追加。
          ここにheightとoverflowを指定する。
      -->
      <div class="header__navi__inner">
        <ul class="header__navi__list">
          <li><a href="#">MENU1</a></li>
          <li><a href="#">MENU2</a></li>
          <li><a href="#">MENU3</a></li>
          <li><a href="#">MENU4</a></li>
          <li><a href="#">MENU5</a></li>
          <li><a href="#">MENU1</a></li>
          <li><a href="#">MENU2</a></li>
          <li><a href="#">MENU3</a></li>
          <li><a href="#">MENU4</a></li>
          <li><a href="#">MENU5</a></li>
          <li><a href="#">MENU1</a></li>
          <li><a href="#">MENU2</a></li>
          <li><a href="#">MENU3</a></li>
          <li><a href="#">MENU4</a></li>
          <li><a href="#">MENU5</a></li>
          <li><a href="#">MENU1</a></li>
          <li><a href="#">MENU2</a></li>
          <li><a href="#">MENU3</a></li>
          <li><a href="#">MENU4</a></li>
          <li><a href="#">MENU5</a></li>
        </ul>
      </div>
    </div>
    </hedaer>
</div>
<!-- /.header -->
<div class="main">
  <p>Contents Area</p>
</div>
<!-- /.main -->
              
            
!

CSS

              
                html {
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  box-sizing: border-box;
}
body {
  margin: 0;
}
body, input, button, textarea, select {
  line-height: 1.5;
  font-family: 'Open Sans', "游ゴシック体", "Yu Gothic", YuGothic, "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, sans-serif;
}
*,
::before,
::after {
  box-sizing: inherit;
}
p {
  margin: 0;
}
a {
  color: #fff;
  text-decoration: none;
}
ul {
  list-style-type: none;
  margin: 0;  
  padding: 0;
}
.header__inner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 5px 15px;
  background-color: #26a69a;
}
.header__title > a {
  font-size: 25px;
  font-weight: bold;
}
.header__menu {
  position: absolute;
  top: 50%;
  right: 15px;
  transform: translateY(-50%);
}
.header__menu > a {
  display: block;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1;
  border: 1px solid #fff;
  border-radius: 3px;
}
.header__navi {
  position: fixed;
  top: 47px;
  left: 0;
  width: 100%;
  z-index: 100;
  text-align: center;
  
}
.header__navi__inner {
  height: 526px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.header__navi__close {
  display: inline-block;
  position: fixed;
  top: 0;
  right: 0;
  margin: 0 0 0 auto;
  font-size: 30px;
  line-height: 1;
  background-color: rgba(0, 0, 0, .8);
}
.header__navi__close > a {
  display: block;
  width: 47px;
  height: 47px;
  padding: 5px 10px;
}
.header__navi__list {
  background-color: rgba(0, 0, 0, .8);
}
.header__navi__list > li:not(:first-child) {
  border-top: 1px solid gray;
}
.header__navi__list > li > a {
  display: block;
  padding: 15px 5px;
}
.main {
  display: table;
  width: 100%;
  height: 1000px;
  background-color: #f9f6e4;
}
.main p {
  display: table-cell;
  font-size: 20px;
  text-align: center;
  vertical-align: middle;
}
              
            
!

JS

              
                var menuBtn = document.getElementById('js-header__menu');
var closeBtn = document.getElementById('js-header__navi__close');
var navi = document.getElementById('js-header__navi');

function headerMenu() {
  menuBtn.style.display = 'none';
  menuBtn.addEventListener('click', function() {
    navi.style.display = 'block';
    menuBtn.style.display = 'none';
  }, false);
  closeBtn.addEventListener('click', function() { 
    navi.style.display = 'none';
    menuBtn.style.display = 'block';
  }, false);
}

document.addEventListener('DOMContentLoaded', headerMenu, false);
              
            
!
999px

Console