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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <!--
  Use:

  <li><span>Label</span></li>     : Labeled item
  <li><a href="...">Link</a></li> : Labeled link item
  <li></li>                       : Empty separator
  <li>Label</li>                  : Labeled separator
  <li class="active">...</li>     : Active item

-->
<nav class="bar-top-menu">
  <ul class="top-menu">
    <li class="active"><a href="#">Home</a></li>
    <li><span>Abaut Us</span>
      <ul>
        <li><a href="#">Team</a></li>
        <li><a href="#">History</a></li>
        <li></li>
        <li><span>Career</span>
          <ul>
            <li><a href="#">Find Jobs</a></li> 
            <li><a href="#">Open Jobs</a></li>
            <li><a href="#">Social sharing</a></li> 
          </ul>
        </li>
      </ul>
    </li>
    <li><a href="#">Products</a>
      <ul>
        <li><a href="#">Online Stores</a></li>
        <li><span>Catalogues</span>
          <ul>
            <li><span>Seasons</span>
              <ul>
                <li><a href="#">Summer</a></li>
                <li><a href="#">Autumn</a></li> 
                <li><a href="#">Winter</a></li> 
                <li><a href="#">Spring</a></li>
              </ul>
            </li>
            <li><span>Tints</span>
              <ul>
                <li><a href="#">Gray openings</a></li>
                <li><a href="#">Rainbow variety</a></li> 
                <li><a href="#">Light-dark shades</a></li> 
                <li><a href="#">Glitter colors</a></li>
              </ul>
            </li>
          </ul>
        </li>
      </ul>
    </li>
    <li><a href="#">Services</a>
      <ul>
        <li>Indoor</li>
        <li><a href="#">One-to-one tutoring</a></li> 
        <li><a href="#">Landscaping</a></li>
        <li><a href="#">Social sharing</a></li> 
        <li>Outdoor</li>
        <li><a href="#">Residential services</a></li> 
        <li><a href="#">Commercial services</a></li>
        <li><a href="#">Standard Business</a></li> 
      </ul>
    </li>
    <li><a href="#">Contact</a></li>
  </ul>
</nav>
              
            
!

CSS

              
                .bar-top-menu{                                              /* Container bar */
  display: flex;
  justify-content: center;
  width: 100%;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.bar-top-menu *{                                            /* Reset box model */
  box-sizing: border-box;
}
ul.top-menu{                                                /* Menu wrapper level 1 */
  display: flex;
  padding: 0;
  margin: 0;
  font: 15px 'Montserrat', sans-serif;
}
ul.top-menu ul{                                             /* Menu wrapper any level */
  width: auto;
  min-width: 80px;
  white-space: nowrap;
  display: none;
  position: absolute;
  margin: 0;
  padding: 0;
  border-style: solid;
  border-width: 0 1px 1px;
  box-shadow: 0 2px 6px -3px #000;
}
ul.top-menu > li > ul{                                      /* Submenu wrapper level 2 */
  left: 0;
  font-size: .75em;
}
ul.top-menu ul ul{                                          /* Submenu wrapper level 3+ */
  top: 0;
  left: 100%
}
ul.top-menu li:hover > ul{                                  /* Submenu wrapper open */
  display: block;
  z-index: 1;
}
ul.top-menu li{                                             /* Menu items any level */
  position: relative;
  list-style-type: none;
}
ul.top-menu > li{                                           /* Menu items level 1 */
  margin: 0;
  padding: 0;
}
ul.top-menu ul > li{                                        /* Submenu items */
  width: 100%;
}
ul.top-menu a{                                              /* Link elements any level */
  color: inherit;
  text-decoration: none;
  outline: none;
}
ul.top-menu li > a:first-child,                             /* Menu items label any level */
ul.top-menu li > span:first-child{
  display: inline-block;
  position: relative;
  border-style: solid;
  border-width: 1px 0;
  font-weight: normal;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  line-height: normal;
  cursor: pointer;
}
ul.top-menu > li > :first-child{                            /* Menu items label level 1 */
  padding: 10px 11px;
}
ul.top-menu ul > li > a:first-child,                        /* Submenu items label */
ul.top-menu ul > li > span:first-child{
  width: 100%;
  padding: 4px .9em;
}
ul.top-menu li{                                             /* Separator with text */
  text-align: center;
  letter-spacing: .2em;
  line-height: 2;
  cursor: default;
}
ul.top-menu li:empty{                                       /* Empty separator */
  height: 7px;
}
ul.top-menu > li > :first-child:not(:last-child):before{    /* Menu items arrow level 1 */
  content: "\25BE";
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: .3em;
  font-size: .9em;
  text-align: center;
  line-height: 0;
  transform: scaleX(2);
  opacity: .7;
}
ul.top-menu ul > li > :first-child:not(:last-child):before{ /* Submenu items arrow */
  content: "\25B8";
  position: absolute;
  right: 0;
  font-size: .9em;
  line-height: 1.3;
  transform: scaleY(2);
  opacity: .7;
}

/* ------------------------------------- COLORS ------------------------------------- */

.bar-top-menu{                                              /* Container bar */
  background: #28529e;
}
ul.top-menu ul{                                             /* Submenu wrapper */
  border-color: #aaa;
}
ul.top-menu > li > :first-child{                            /* Menu items level 1 */
  color: #fff;
  border-color: transparent;
}
ul.top-menu > li:hover > :first-child{                      /* Hover menu items level 1 */
  background: #eef2f8;
  color: #000;
}
ul.top-menu ul > li > a:first-child,                        /* Submenu items */
ul.top-menu ul > li > span:first-child{
  background: #dfdfdf;
  color: #000;
  border-top-color: #eef2f8;
  border-bottom-color: transparent;
}
ul.top-menu ul > li:hover > a:first-child,                  /* Hover submenu items */
ul.top-menu ul > li:hover > span:first-child{
  background: #eef2f8;
  color: #000;
  border-color: #aaa;
}
ul.top-menu > li.active > :first-child{                     /* Active menu item level 1 */
  background: #fff;
  color: #26282a;
  border-color: #eef;
}
ul.top-menu ul > li.active > a:first-child,                 /* Active submenu item */
ul.top-menu ul > li.active > span:first-child{
  background: #fff;
  border-color: #aaa;
}
ul.top-menu ul > li{                                        /* Separator */
  background: #5771a1;
  color: #fb5;
  border-color: #555;
}

              
            
!

JS

              
                /* Simulation of the active item on click */
;( function(){
  var menuLinks = document.querySelectorAll('.bar-top-menu ul>li>a');
  for (let i = 0; i < menuLinks.length; i++) {
    menuLinks[i].addEventListener('click', function() {
      var activeItems = document.querySelectorAll('.bar-top-menu ul>li.active');
      [].forEach.call(activeItems, function(el) {
        el.classList.remove('active');
      });
        (function applyActive(el){
          console.log('in',el);
          el = el.parentNode.closest('li');
          console.log('out',el);
          if(!el) return;
          el.classList.add('active');
          applyActive(el);
        })(this)
      });
    }
})();
              
            
!
999px

Console