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

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

              
                <header>
  <a class="menu-trigger" href="#">
    <span></span>
    <span></span>
    <span></span>
  </a>
  <div class="modalWrap">
    <nav>
      <ul>
        <li><a href="#">MENU01</a></li>
        <li><a href="#">MENU02</a></li>
        <li><a href="#">MENU03</a></li>
        <li><a href="#">MENU04</a></li>
        <li><a href="#">MENU05</a></li>
        <li><a href="#">MENU06</a></li>
        <li><a href="#">MENU07</a></li>
        <li><a href="#">MENU08</a></li>
        <li><a href="#">MENU09</a></li>
        <li><a href="#">MENU10</a></li>
      </ul>
    </nav>
  </div>
</header>


<div id="section-contents">
  <div style="padding:30px;height:3000px;">CONTENTS</div> 
</div>
              
            
!

CSS

              
                /*-------------------------------------------------------------
  humberger settings
-------------------------------------------------------------*/

.menu-trigger {
  display: inline-block;
  box-sizing: border-box;
  position: fixed;
  right: 20px;
  top: 20px;
  width: 30px;
  height: 24px;
  z-index: 9999;
  transition: transform .4s;
  span {
    display: inline-block;
    transition: transform .4s;
    box-sizing: border-box;
    position: absolute;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: #000;
    border-radius: 4px;
    &:nth-of-type(1) {
      top: 0;
    }
    &:nth-of-type(2) {
      top: 10px;
    }
    &:nth-of-type(3) {
      bottom: 0;
    }
  }
  &.active {
    span {
      &:nth-of-type(1) {
        transform: translateY(10px) rotate(-315deg);
      }
      &:nth-of-type(2) {
        opacity: 0;
      }
      &:nth-of-type(3) {
        transform: translateY(-10px) rotate(315deg);
      }
    }
  }
}


/*-------------------------------------------------------------
  modalNav settings
-------------------------------------------------------------*/

.modalWrap {
  display: none;
  position: fixed;
  background: rgba(255, 255, 255, 0.9);
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  z-index: 9998;
  nav {
    ul {
      padding: 60px 0;
      li {
        text-align: center;
        &:nth-child(2n + 0) {
          background-color: #fff;
        }
        &:nth-child(2n + 1) {
          background-color: rgb(234, 234, 234);
        }
        a {
          display: block;
          font-size: 18px;
          padding: 30px 0;
          text-decoration: none;
          color: #000;
        }
      }
    }
  }
}
              
            
!

JS

              
                #------------------------------------------------------
# 各変数の定義
#------------------------------------------------------

current_scrollY = undefined
current_scrollsize = undefined
$current_target = $('#section-contents')
$current_trigger = $('.menu-trigger')
$current_trigger_pos = undefined

#------------------------------------------------------
# ハンバーガーメニューを押した時の処理
#------------------------------------------------------

$current_trigger.on 'click', ->
  $this_trigger = $(this)
  $this_trigger.toggleClass 'active'
  $this_trigger.next().animate { opacity: 'toggle' },
    duration: 'slow'
    easing: 'linear'
  
  if $this_trigger.hasClass('active')
    # $this_trigger.next().show()
    $this_trigger.css { right: $current_trigger_pos + current_scrollsize }
    current_scrollY = $(window).scrollTop()
    $current_target.css
      position: 'fixed'
      width: '100%'
      top: -1 * current_scrollY
  else
    # $this_trigger.next().hide()
    $this_trigger.css { right: '' }
    $current_target.attr style: ''
    $('html, body').prop scrollTop: current_scrollY

  false

#------------------------------------------------------
# モーダルの幅と高さを調整(リサイズも対応)
#------------------------------------------------------

$(window).on 'load resize', ->
  # height取得
  disHm = '-' + window.innerHeight
  disHp = window.innerHeight
  disHm = Number(disHm)
  disHp = Number(disHp)
  # width取得
  disWm = '-' + document.documentElement.clientWidth
  disWp = document.documentElement.clientWidth
  disWm = Number(disWm)
  disWp = Number(disWp)
  current_scrollsize = window.innerWidth - $(window).width()
  $current_trigger_pos = parseInt $current_trigger.css('right').replace('px', '')
  # モーダルの高さを取得
  $('.modalWrap').css
    # height: disHp
    width: disWp + current_scrollsize
  return
              
            
!
999px

Console