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

              
                <nav role="navigation" class="priority-nav">
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Clients</a></li>
    <li><a href="#">Contact Us</a></li>
    <li><a href="#">Buy Lemons</a></li>
    <li><a href="#">Dance Wildly</a></li>
    <li><a href="#">Go To Bed</a></li>
    <li><a href="#">Donate Millions</a></li>
    <li class="overflow-nav">
      <span class="overflow-nav-title">
        ▼
      </span>
      <ul class="overflow-nav-list"></ul>
    </li>
  </ul>
</nav>  
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro);

.priority-nav {
  background: #f06d06;
  height: 40px; // not ideal... do with JS?
  > ul {
    list-style: none;
    > li {
      display: inline-block;
      position: relative;
      &.overflow-nav {
        display: none;
      }
    }
  }
  a {
    text-decoration: none;
    color: white;
    display: inline-block;
    padding: 10px 15px;
  }
  &.resizing {
    overflow: hidden;
  }
}

.overflow-nav-list {
  background: white;
  box-shadow: 0 0 10px rgba(black, 0.35);
  position: absolute;
  top: 95%; // moves to 100% on hover generally
  right: 0;
  opacity: 0;
  visibility: hidden;
  padding: 5px 0;
  width: 200px;
  color: #222;
  a {
    color: black;
    font-weight: bold;
    &:hover,
    &:active {
      background: #f06d06;
      color: white;
    }
  }
  list-style: none;
  z-index: 1;
  right: -20px;
  &.show {
    opacity: 1;
    visibility: visible;
  }
  > li > a,
  .primary > a {
    color: black;
    display: block;
  }
  .primary-last {
    margin-right: 0;
  }
}
.overflow-nav-title {
  cursor: pointer;
  text-align: center;
  background: white;
  color: #222;
  border-radius: 50%;
  font-size: 10px;
  width: 2em;
  height: 2em;
  line-height: 2.2em;
  vertical-align: top;
  display: inline-block;
}

.hide {
  display: none !important;
}
.show-inline-block {
  display: inline-block !important;
}

body {
  font-family: 'Source Sans Pro', sans-serif;
}
              
            
!

JS

              
                var PriorityNav = {

  // used multiple times, so saving.
  menu: $(".priority-nav"),
  allNavElements: $(".priority-nav > ul > li:not('.overflow-nav')"),

  init: function() {
    this.bindUIActions();
    this.setupMenu();
  },

  setupMenu: function() {
    
    // Checking top position of first item (sometimes changes)
    var firstPos = $(".priority-nav > ul > li:first").position();
        
    // Empty collection in which to put menu items to move
    var wrappedElements = $();

    // Used to snag the previous menu item in addition to ones that have wrapped
    var first = true;

    // Loop through all the nav items...
    PriorityNav.allNavElements.each(function(i) {
      
      var el = $(this);

      // ...in which to find wrapped elements
      var pos = el.position();
                  
      if (pos.top !== firstPos.top) {

        // If element is wrapped, add it to set
        wrappedElements = wrappedElements.add(el);

        // Add the previous one too, if first
        if (first) {
          wrappedElements = wrappedElements.add(PriorityNav.allNavElements.eq(i-1));
          first = false;
        }
      }
    });
        
    if (wrappedElements.length) {

      // Clone set before altering
      var newSet = wrappedElements.clone();

      // Hide ones that we're moving
      wrappedElements.addClass("hide");

      // Add wrapped elements to dropdown
      $(".overflow-nav-list").append(newSet);

      // Show new menu
      $(".overflow-nav").addClass("show-inline-block");

      // Make overflow visible again so dropdown can be seen.
      $(".priority-nav").css("overflow", "visible");

    }
  },

  tearDown: function() {
    $(".overflow-nav-list").empty();
    $(".overflow-nav").removeClass("show-inline-block");
    PriorityNav.allNavElements.removeClass("hide");
  },

  bindUIActions: function() {
    $(".overflow-nav-title").on("click", function() {
      $(".overflow-nav-list").toggleClass("show");
    });

    $(window)
      .resize(function() {
        PriorityNav.menu.addClass("resizing");
      })
      .resize(_.debounce(function() {
        PriorityNav.tearDown();
        PriorityNav.setupMenu();
        PriorityNav.menu.removeClass("resizing");
      }, 500));
  }

}

PriorityNav.init();

              
            
!
999px

Console