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

              
                <div class="container">
  <div class="header">
    <div class="menu-icon" data-behaviour="toggle-menu-icon">
      <span class="menu-icon__bar">
    </div>
  </div>
  <nav class="nav" data-element="toggle-nav">
    <ul class="nav__list">
      <li class="nav__item">
        <a class="nav__link" href="#">Menu item One</a>
      </li>
      <li class="nav__item">
        <a class="nav__link nav__link--plus" data-behaviour="toggle-link-icon" href="#">Menu item Two</a>
        <ul class="nav__sub-list" data-behaviour="toggle-sub-menu">
          <li class="nav__sub-item">
            <a class="nav__link"  href="#">Sub Menu item one</a>
          </li>
          <li class="nav__sub-item">
            <a class="nav__link" href="#">Sub Menu item two</a>
          </li>
          <li class="nav__sub-item">
            <a class="nav__link" href="#">Sub Menu item three</a>
          </li>
        </ul>
      </li>
      <li class="nav__item">
        <a class="nav__link" href="#">Menu item Three</a>
      </li>
      <li class="nav__item">
        <a class="nav__link" href="#">Menu item Four</a>
      </li>
    </ul>
  </nav>
</div>
              
            
!

CSS

              
                @import "bourbon@5.*"
@import url('https://fonts.googleapis.com/css?family=Questrial')

body
  +padding(20px)
.container
  +margin(0 auto)
  +size(320px, 568px)
  background-color: #C14500
  position: relative
.header
  +padding(20px)
  background-color: #222
.menu-icon
  +size(25px, 20px)
  position: relative
  &:hover
    cursor: pointer
    .menu-icon__bar
      opacity: .6  
  &__bar
    +position(absolute, 50% null null)
    +size(100%, 2px)
    background-color: #fff
    display: block
    transition: opacity .3s ease
    &::before,
    &::after
      +size(100%, 2px)
      content: ''
      background-color: #fff
      display: block
      position: absolute
      transition: transform .5s ease
    &::before
      top: -10px
    &::after
      bottom: -10px
  &--open
    .menu-icon
      position: relative
      &__bar
        background: transparent
        &::before,
        &::after
          top: 50%
          transform: translateY(-50%)
        &::after
          transform: rotate(135deg)
        &::before
          transform: rotate(-135deg)  
.nav
  +padding(20px)
  +position(absolute, -1400px null null)
  background-color: #222
  transition: top .6s ease
  width: 55%
  &--active
    +position(absolute, 60px null null)
  &__list
    padding-left: 0
    list-style: none
  &__item
    font-family: 'Questrial', sans-serif
    margin-bottom: 10px
    text-align: left
  &__link
    +position(relative, null null)
    color: #fff
    text-decoration: none
    &--plus,
    &--minus
      &::after
        color: #fff
        font-family: FontAwesome
        font-size: 10px
        +position(absolute, 50% -20px null null)
        transform: translateY(-50%)
    &--plus::after
      content: '\f067'
    &--minus
      color: #C14500
      &::after
        content: "\f068"
        color: #C14500
    &:hover
      opacity: .6
  &__sub-list
    +margin(10px null)
    +padding(10px null 10px 10px)
    border-top: 1px solid rgba(255, 255, 255, .6)
    border-bottom: 1px solid rgba(255, 255, 255, .6)
    displaY: none
    list-style: none
    padding-left: 10px
    &--active
      display: block
      
  &__sub-item
    .nav__link
      color: rgba(255, 255, 255, .6)
    &:not(:last-child)
      padding-bottom: 10px
              
            
!

JS

              
                $(function() {
  function init() {
    $('[data-behaviour="toggle-menu-icon"]').on('click', toggleMenuIcon);
    $('[data-behaviour="toggle-link-icon"]').on('click', toggleSubMenu);
  };
  
  function toggleMenuIcon() {
    $(this).toggleClass('menu-icon--open');
    $('[data-element="toggle-nav"]').toggleClass('nav--active');
  };
  
  function toggleSubMenu() {
    $(this).toggleClass('nav__link--plus nav__link--minus');
    $('[data-behaviour="toggle-sub-menu"]').slideToggle('nav__sub-list--active');
  };
  
  init()
});
              
            
!
999px

Console