123

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.

            
              <header>
  <nav id="Nav">
    <ul>
      <li class="selected"><a href="http://example.com/?1" id="item01" aria-current="page">Home</a></li>
      <li>
        <a href="http://example.com/?2" id="Item02">Accounts</a>
        <button type="button" id="btnItem02" aria-controls="SubItem02" aria-expanded="false" aria-label="Show" aria-labelledby="btnItem02 Item02" onclick="toggleSubNav(this.id);">
        <svg xmlns="http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg>
          </button>
        <ul id="SubItem02" style="display:none;">
          <li><a href="http://example.com/?2a">Holdings</a></li>
          <li><a href="http://example.com/?2b">Liabilities</a></li>
          <li><a href="http://example.com/?2c">Activity</a></li>
          <li><a href="http://example.com/?2d" aria-current="page">Realized Gain / Loss</a></li>
          <li><a href="http://example.com/?2e">Portfolio Analytics</a></li>
          <li><a href="http://example.com/?2f">Documents</a></li>
        </ul>
      </li>
      <li>
        <a href="http://example.com/?3" id="Item03">Access Investing</a></li>
      <li><a href="http://example.com/?4" id="Item04">Pay, Transfer + Budget</a>
        <button type="button" id="btnItem04" aria-controls="SubItem04" aria-expanded="false" aria-label="Show" aria-labelledby="btnItem04 Item04" onclick="toggleSubNav(this.id);">
        <svg xmlns="http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg>
          </button>
        <ul id="SubItem04" style="display:none;">
          <li><a href="http://example.com/?4a">Payments</a></li>
          <li><a href="http://example.com/?4b">Transfers</a></li>
          <li><a href="http://example.com/?4c">Send Money with Zelle&reg;</a></li>
          <li><a href="http://example.com/?4d">Spending + Budgeting</a></li>
          <li><a href="http://example.com/?4e">Premier Cash Management</a></li>
        </ul>
      </li>
      <li>
        <a href="http://example.com/?5" id="Item05">Markets + Research</a>
        <button type="button" id="btnItem05" aria-controls="SubItem05" aria-expanded="false" aria-label="Show" aria-labelledby="btnItem05 Item05" onclick="toggleSubNav(this.id);">
        <svg xmlns="http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg>
          </button>
        <ul id="SubItem05" style="display:none;">
          <li><a href="http://example.com/?5a">US Markets</a></li>
          <li><a href="http://example.com/?5b">World Markets</a></li>
          <li><a href="http://example.com/?5c">Research</a></li>
          <li><a href="http://example.com/?5d">Strategy and Economics</a></li>
          <li><a href="http://example.com/?5e">News</a></li>
          <li><a href="http://example.com/?5f">Screeners</a></li>
          <li><a href="http://example.com/?5g">Fixed Income Offerings</a></li>
          <li><a href="http://example.com/?5h">Watchlist</a></li>
        </ul>
      </li>
      <li>
        <a href="http://example.com/?6" id="Item06">Trade</a>
        <button type="button" id="btnItem06" aria-controls="SubItem06" aria-expanded="false" aria-label="Show" aria-labelledby="btnItem06 Item06" onclick="toggleSubNav(this.id);">
        <svg xmlns="http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg>
          </button>
        <ul id="SubItem06" style="display:none;">
          <li><a href="http://example.com/?6a">Order Status</a></li>
          <li><a href="http://example.com/?6b">Unsettled Trades</a></li>
          <li><a href="http://example.com/?6c">Stocks + ETFs</a></li>
          <li><a href="http://example.com/?6d">Mutual Funds</a></li>
          <li><a href="http://example.com/?6e">Options</a></li>
        </ul>
      </li>
      <li><a href="http://example.com/?7" id="Item07">Home Loans</a></li>
      <li>
        <a href="http://example.com/?8" id="Item08">Services</a>
        <button type="button" id="btnItem08" aria-controls="SubItem08" aria-expanded="false" aria-label="Show" aria-labelledby="btnItem08 Item08" onclick="toggleSubNav(this.id);">
        <svg xmlns="http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg>
          </button>
        <ul id="SubItem08" style="display:none;">
          <li><a href="http://example.com/?8a">Account Services</a></li>
          <li><a href="http://example.com/?8b">eDelivery</a></li>
          <li><a href="http://example.com/?8c">Profile + Settings</a></li>
          <li><a href="http://example.com/?6d">Manage Alerts</a></li>
          <li><a href="http://example.com/?6e">eAuthorizations</a></li>
        </ul>
      </li>
    </ul>
  </nav>
</header>
<main>
  <h1>Navigation</h1>
  <p>
    Made the buttons minimum 44px &times; 44px to comply with <a href="https://www.w3.org/WAI/WCAG21/quickref/#target-size">2.5.5
    Target Size (AAA)</a>.
  </p>
  <p>
    Not done, owing to flex as child of flex, nested lists that open outside window, nested lists that do not close when clicking randomly on the page.
  </p>
</main>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Open+Sans');

body {
  background-color: #eeeeee;
  font-size: 100%;
  color: #333;
  font-family: 'Open Sans', Verdana, sans-serif;
  padding: 0;
  margin: 0;
}

body * {
  box-sizing: border-box;
}

header,
nav,
main {
  display: block;
  box-sizing: border-box;
  width: auto;
  padding: 1em 1vw;
  margin: 1em 1vw;
  color: #000;
}

header,
nav {
  padding: 0;
  margin: 0;
}

nav {
  margin-top: 0.5em;
  background-color: #ddd;
  font-size: 90%;
  border-top: 0.2em solid #ccc;
}

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

nav > ul {
  display: flex;
  flex-wrap: nowrap; /* RWD */
  justify-content: space-evenly;
  align-items: stretch;
}

nav > ul > li {
  flex: 1 1 auto; /* RWD */
  margin: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  align-content: flex-start;
  padding: 0;
  border-right: 0.2em solid #ccc;
  border-bottom: 0.2em solid #ccc;
  position: relative;
}

nav > ul > li:first-child {
  border-left: 0.2em solid #ccc;
}

nav > ul > li > a {
  padding: 1em;
  text-align: center;
}

nav > ul > li > * {
  flex: 1 1 44px;
  box-sizing: border-box;
}

nav > ul > li > button {
  flex: 0 0 44px;
  border: none;
  border-left: 0.1em solid #000;
  line-height: 0;
  outline: none;
  text-align: center;
  padding: 0;
  margin: 0 0 0 1em;
}

nav > ul > li > a + button svg {
  width: 1em;
  height: 1em;
  fill: #000;
  transition: transform 0.25s ease-in;
  transform-origin: center 45%;
}

button[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

nav > ul li > ul {
  position: absolute;
  top: 100%;
  left: -0.1em;
  right: -0.5em;
  width: auto;
  min-width: 12em;
  height: auto;
  overflow: visible;
  z-index: 10;
  margin: 0;
  padding: 1em 0;
  border: 0.01em solid transparent;
}

nav > ul ul a {
  display: block;
  font-size: 95%;
  margin: 0;
  padding: 0.5em 1.3em;
}

nav > ul ul a:hover,
nav > ul ul a:focus {
  background-color: #ccc;
}

@media screen and (min-width: 60em) {
  /* At arbitrary desktop width, keep right menu from going out of viewport */
  nav > ul li:last-child > ul {
    left: auto;
    right: 0;
  }
}

@media screen and (max-width: 60em) {
  body {
    background-color: #ffe;
  }
  nav > ul {
    /* Has to happen in a max-width MQ */
    /* Sorry, no mobile-first in this case */
    flex-wrap: wrap; /* RWD */
  }
  nav > ul > li {
    border-right: 0.1em solid #ccc;
    border-left: 0.1em solid #ccc;
  }
  nav > ul > li:first-child {
    border-left-width: 0.1em;
  }
  nav > ul li > ul {
    right: 0;
  }
}

@media screen and (-ms-high-contrast: active) {
  nav {
    border-top: 0.1em solid windowText;
  }
}

/* Colors */

nav {
  border-color: #0f5f8c;
}

nav,
nav ul,
nav button,
nav > ul ul a:hover,
nav > ul ul a:focus {
  background-color: #013461;
}

nav a,
nav a:link,
nav a:visited,
nav a:hover,
nav a:focus,
nav a:active {
  color: #fff;
  text-decoration: none;
  outline: none;
}

nav > ul > li > a + button svg {
  fill: #fff;
}

nav > ul > li,
nav > ul > li > button,
nav > ul > li:first-child {
  border-color: #0f5f8c;
}

nav > ul > li > button:hover,
nav > ul > li > button:focus {
  border-color: rgba(255,255,255,.2);
  background-color: transparent;
}

nav > ul > li:hover,
nav > ul > li > a:hover,
nav > ul > li > a:focus,
nav > ul li > ul {
  background-color: #005c90;
}

nav > ul > li:focus-within {
  /* Keep separate for IE11 */
  background-color: #005c90;
}

nav > ul > li a[aria-current="page"],
nav > ul > li:hover a[aria-current="page"],
nav > ul > li:focus a[aria-current="page"],
nav > ul > li.selected,
nav > ul > li.selected:hover {
  background-color: #187aba;
  border-color: #187aba;
}

            
          
!
            
              
// Get the nav by id
var pNav = document.getElementById("Nav");

function toggleSubNav(eID) {
  try {
    // Get all the top-level items and get the buttons
    var allButtons = document.querySelectorAll("#Nav > ul > li > a + button");
    // Get all sub-menus
    var allSubMenus = document.querySelectorAll("#Nav > ul > li > a + button + ul");
    if (eID !== "") {
      // Get the button
      var toggle = document.querySelector("#" + eID);
      // Find out what the button controls
      var subMenuIdent = toggle.getAttribute("aria-controls");
      // Get that thing it controls
      var subMenu = document.getElementById(subMenuIdent);
      // Toggle text and expanded state
      if (toggle.getAttribute("aria-expanded") === "false") {
        // Loop through all buttons and mark as closed
        for (var i = 0; i < allButtons.length; i++) {
          allButtons[i].setAttribute("aria-expanded", "false");
          allButtons[i].setAttribute("aria-label", "Show");
        //   allButtons[i].innerHTML = arrowShow;
        }
        // Now mark the chosen button as opened
        toggle.setAttribute("aria-expanded", "true");
        toggle.setAttribute("aria-label", "Hide");
      } else {
        // Close chosen button; no need to loop through rest of nodes
        toggle.setAttribute("aria-expanded", "false");
        toggle.setAttribute("aria-label", "Show");
      }
      // Expand or collapse
      if (subMenu.style.display === "none") {
        // Hide all submenus
        for (var i = 0; i < allSubMenus.length; i++) {
          allSubMenus[i].style.display = "none";
        }
        // Show chosen submenu
        subMenu.style.display = "block";
      } else {
        // Close chosen menu; no need to loop through rest of nodes
        subMenu.style.display = "none";
      }
    }
    if (eID !== "") {
    } else {
      // Hide all submenus
      for (var i = 0; i < allSubMenus.length; i++) {
        allSubMenus[i].style.display = "none";
      }
      // Loop through all buttons and mark as closed
      for (var i = 0; i < allButtons.length; i++) {
        allButtons[i].setAttribute("aria-expanded", "false");
        allButtons[i].setAttribute("aria-label", "Show");
        // allButtons[i].innerHTML = arrowShow;
      }
    }
  } catch (e) {
    console.log("toggleSubNav(): " + e);
  }
}

document.onkeydown = function(evt) {
  evt = evt || window.event;
  var isEscape = false;
  if ("key" in evt) {
    isEscape = evt.key == "Escape" || evt.key == "Esc";
  } else {
    isEscape = evt.keyCode == 27;
  }
  if (isEscape) {
    //alert("Escape");
    toggleSubNav("");
  }
};


            
          
!
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.

Console