css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <div class="container example-one">
  <div class="title">All scrolling (using JS)</div>
  <header class="bg-dark-blue radius">
    <nav class="nav scroll">
      <span class="vam logo">Logo</span>
      <span class="nav-item active" data-id="blog" aria-controls="blog">Blog</span>
      <span class="nav-item" data-id="portfolio" aria-controls="portfolio">Portfolio</span>
      <span class="nav-item">Downloads</span>
      <span class="nav-item">About</span>
      <span class="nav-item">Contact</span>
    </nav>
    <div class="bg-grey submenu scroll active" id="blog">
      <span class="nav-item">All</span>
      <span class="nav-item">Design</span>
      <span class="nav-item">Illustrator</span>
      <span class="nav-item">Photoshop</span>
      <span class="nav-item">Development</span>
      <span class="nav-item">CSS</span>
      <span class="nav-item">JavaScript</span>
    </div>
    <div class="bg-grey submenu scroll" id="portfolio">
      <span class="nav-item">All</span>
      <span class="nav-item">Branding</span>
      <span class="nav-item">Illustration</span>
      <span class="nav-item">Web</span>
      <span class="nav-item">UX</span>
      <span class="nav-item">Print</span>
      <span class="nav-item">App</span>
    </div>
  </header>
</div>

<div class="container example-two">
  <div class="title">Logo scrolling (using JS)</div>
  <header class="radius">
    <div class="bg-dark-blue">
      <span class="logo vam">Logo</span>
      <nav class="vam nav scroll">
        <span class="nav-item" data-id="blog-2" aria-controls="blog-2">Blog</span>
        <span class="nav-item" data-id="portfolio-2" aria-controls="portfolio-2">Portfolio</span>
        <span class="nav-item">Downloads</span>
        <span class="nav-item">About</span>
        <span class="nav-item">Contact</span>
      </nav>
    </div>
    <div class="bg-grey submenu scroll radius-bottom" id="blog-2">
      <span class="nav-item">All</span>
      <span class="nav-item">Design</span>
      <span class="nav-item">Illustrator</span>
      <span class="nav-item">Photoshop</span>
      <span class="nav-item">Development</span>
      <span class="nav-item">CSS</span>
      <span class="nav-item">JavaScript</span>
    </div>
    <div class="bg-grey submenu scroll" id="portfolio-2">
      <span class="nav-item">All</span>
      <span class="nav-item">Branding</span>
      <span class="nav-item">Illustration</span>
      <span class="nav-item">Web</span>
      <span class="nav-item">UX</span>
      <span class="nav-item">Print</span>
      <span class="nav-item">App</span>
    </div>
  </header>
</div>

<div class="container example-three">
  <div class="title">Logo scrolling (using JS)</div>
  <header class="radius">
    <div class="bg-dark-blue text-center">
      <span class="logo vam">Logo</span>
    </div>
    <nav class="nav scroll bg-grey">
      <span class="nav-item" data-id="blog-3" aria-controls="blog-3">Blog</span>
      <span class="nav-item" data-id="portfolio-3" aria-controls="portfolio-3">Portfolio</span>
      <span class="nav-item">Downloads</span>
      <span class="nav-item">About</span>
      <span class="nav-item">Contact</span>
    </nav>
    <div class="bg-grey submenu scroll" id="blog-3">
      <span class="nav-item">All</span>
      <span class="nav-item">Design</span>
      <span class="nav-item">Illustrator</span>
      <span class="nav-item">Photoshop</span>
      <span class="nav-item">Development</span>
      <span class="nav-item">CSS</span>
      <span class="nav-item">JavaScript</span>
    </div>
    <div class="bg-dark-grey submenu scroll" id="portfolio-3">
      <span class="nav-item">All</span>
      <span class="nav-item">Branding</span>
      <span class="nav-item">Illustration</span>
      <span class="nav-item">Web</span>
      <span class="nav-item">UX</span>
      <span class="nav-item">Print</span>
      <span class="nav-item">App</span>
    </div>
  </header>
</div>
            
          
!
            
              /**
 * Code you need
 */
.scroll {
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: -ms-autohiding-scrollbar; }
  
.nav-item.active {
  color: #fff;
  box-shadow: -1px 0 #727c87, 1px 0 #727c87;
  background-color: #727c87; }

.submenu {
  height: 0;
  opacity: 0; }

.submenu.active {
  height: auto;
  opacity: 1; }

/**
 * Helper
 */
.bg-dark-blue {
  background-color: #152637; }

.bg-grey {
  background-color: #727c87; }

.bg-dark-grey {
  background-color: #555f6a; }

.radius {
  border-radius: 3px; }

.radius-top {
  border-radius: 3px 3px 0 0; }

.radius-bottom {
  border-radius: 0 0 3px 3px; }
  
.text-center {
  text-align: center; }

.vam,
.nav-item {
  display: inline-block;
  vertical-align: middle; }
  
/**
 * Example specific
 */
.example-two .logo {
  width: 27.5%; }

.example-two .nav {
  width: 72.5%; }

.example-three .logo {
  border: none; }

.example-three .nav-item.active,
.example-three .submenu .nav-item {
  color: #fff;
  box-shadow: -1px 0 #555f6a, 1px 0 #555f6a;
  background-color: #555f6a; }

/**
 * Visual style
 */
.logo {
  text-align: center;
  font-weight: 700;
  color: #727c87;
  border-right: 1px solid rgba(114, 124, 135, .2);
  padding: 13px 32px 12px; }

.nav-item {
  cursor: pointer;
  padding: 13px 16px 12px; }

.nav-item:not(:last-child) {
  border-right: 1px solid rgba(114, 124, 135, .2); }
  
  .bg-grey .nav-item { color: #fff; }

.submenu {
  border-radius: 0 0 3px 3px; }

header,
nav {
  font-size: 0; }

header {
  overflow: hidden; }

.logo,
.nav-item {
  font-size: 14px; }

.title {
  margin: 24px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: #999; }

/**
 * Setup
 */
* {
  box-sizing: border-box; }

body {
  max-width: 360px;
  margin: 5% auto;
  color: #64cce3;
  line-height: 1.5; }

a { 
  color: #64cce3;
  text-decoration: none; }

ul, li { list-style: none; margin: 0; padding: 0; }

// Demo purposes only, proceed with caution on Windows!
.scroll::-webkit-scrollbar {
  display: none; }
            
          
!
            
              (function (window, document, undefined) {
  'use strict';
  
  // Select nav items that have submenus
  var hasSubmenu = document.querySelectorAll('[data-id]');
  var active = 'active';
  var i = 0;
  
  // Show the submenu by toggling the relevant class names
  function showSubmenu (event) {
    // We lose reference of this when filtering the nav items
    var self = this;
    
    // Select the relevant submenu, by the data-id attribute
    var submenu = document.getElementById(self.dataset.id);
    
    // Probably best to prevent clicks through
    event.preventDefault();
    
    // Referring to the submenu parentNode
    // find all elements that aren't the submenu and remove active class
    var otherSubmenu = Array.prototype.filter.call(
      submenu.parentNode.children, 
      function(child) {
        if ( child !== submenu ) {
          removeChildClass(child);
        }
      });
    
    // Referring to the the nav item parentNode
    // find all elements that aren't the submenu and remove active class
    var otherItem = Array.prototype.filter.call(
      self.parentNode.children, 
      function(child) {
        if ( child !== self ) {
          removeChildClass(child);
        }
      });

    self.classList.toggle(active);
    submenu.classList.toggle(active);
  }
  
  // Remove the active class
  function removeChildClass(el) {
    // Check if it exists, then remove
    if ( el.classList.contains(active) ) {
      el.classList.remove(active);
    }
  }
  
  // On clicks show submenus
  for ( i = 0; i < hasSubmenu.length; i++ ) {
    hasSubmenu[i].addEventListener('click', showSubmenu);
  }
})(window, document);
            
          
!
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.
Loading ..................

Console