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

              
                <!--[if !IE]> -->
<div id="menu_wrapper" class="menu_wrapper">
  <ul class="menu_list">
    <li class="list" name="item">
      <a href="#" name="single">ONE</a>
    </li>
    <li class="list" name="item">        
      <a href="#" name="expand">TWO &#9660;</a>
      <ul name="sub_menu" class="submenu_list">
        <li class="sub_list"><a href="#">TWO-0</a></li>
        <li class="sub_list"><a href="#">TWO-1</a></li>
      </ul>
    </li>
    <li class="list" name="item">
      <a href="#" name="single">THREE</a>
    </li>
    <li class="list" name="item">
      <a href="#" name="single">FOUR</a>
    </li>
    <li class="list" name="item">
      <a href="#" name="expand">FIVE &#9660;</a>
      <ul name="sub_menu" class="submenu_list">
        <li class="sub_list"><a href="#">FIVE-0</a></li>
        <li class="sub_list"><a href="#">FIVE-1</a></li>
        <li class="sub_list"><a href="#">FIVE-2</a></li>
      </ul>
    </li>
  </ul>
</div>
<h1 style="text-align:center"><strike>Fake</strike> Basic menu navigation</h1>
<div style="text-align:center;">
  <img style="width:80px;height:auto;opacity:.4" src="http://assets.johanpaul.net/images/Monkey_Saur.png"></img>
</div>
<!-- <![endif]-->
    
<!--[if IE]>
  <div style="font-size:2em;padding:20px;text-align:center;">
    Not suitable for old Internet Explorer
    <br><br>
    <span style="font-size:12px">*catface</span>
  </div>
<![endif]-->
              
            
!

CSS

              
                body {
  background:#eee;
  font-family:consolas,courier,monospace;
  margin:0;
  padding:0;
}
.menu_list, .submenu_list {
  list-style:none;
  background:#333;
  color:#888;
  font-family:consolas,courier,monospace;
}
.menu_list, .submenu_list,
.list , .sub_list {
  display:inline-block;
  text-align:center;
  padding:0;
  margin:0;
}
.sub_list > a, .list > a {
  color:#888;
  text-decoration:none;
  display:block;
}
.list, .sub_list {
  position:relative;
  width:100px;
}     
.list > a, .sub_list > a {
  border:10px solid transparent;   
  padding:10px;
}
.list:hover > a, .list > a:focus,
.expand:hover, .sub_list:hover> a,
.sub_list > a:focus {
  color:#fff;
  border-bottom:10px solid #fff;
  border-top:10px solid #fff;
  outline:0;
}
.sub_list:hover> a, .sub_list > a:focus {
  border-top:10px solid transparent;
}
.expand:hover{
  cursor:pointer;
}
.menu_wrapper {
  text-align:center;
  background:#333;
}
.submenu_list {
  display:none;
  position:absolute;     
  z-index:1000;      
}     
.sub_list {
  width:auto;
}
              
            
!

JS

              
                //updated Nov 24, 2014
(function (d, w) {
  var expander = 
      d.getElementsByName("expand"),
      submenu = 
      d.getElementsByName("sub_menu"),
      i = 0;
  //for collapsing    
  function clear(){
    var k = 0; //local variable
    //collapsing list
    for (k; k < submenu.length; k++) {
      if (submenu[k]
          .getAttribute("data-expand")) {
        submenu[k]
          .style.display =  "none";
        submenu[k]
          .removeAttribute("data-expand");
      }
    }     
  }
  //for expanding-collapsing list
  function expandCollapse(e,index) {        
    e.preventDefault();
    //expand list on parent click
    if (!submenu[index].getAttribute("data-expand")) { 
        clear();
        submenu[index]
          .style.display =  "block";
        submenu[index]
          .setAttribute("data-expand", 1);
    } else {
      clear();
    }
  }
  //this is for expanding list element
  function expander_func(index) {          
    expander[i].onclick =
        function (e) { 
          expandCollapse(e,index);
        };
  }
  for (i; i < expander.length; i++) {        
    expander_func(i);
  }
  //collapsing menu if the click target is 
  //outside the expanding ones
  w.addEventListener("click", function (e) {
    if (e.target.getAttribute("name") !== "expand") { clear(); }
  });
}(document, window));
              
            
!
999px

Console