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

              
                <!-- Forked in 2020 from https:codepen.io/ArleyM/pen/Cmwgn -->

  <h1>Responsive breadcrumb navigation 2020</h1>
  <p>To navigate by keyboard click around here, then start using the tab key to jump to the links.
  <header>Header</header>

  <nav id="js-crumbs" class="w-crumbs" aria-labelledby="crumb-navigation">
    <!-- MDN showed an example of a title in a <nav> used for a11y reasons, but elsewhere it was suggested this may not be semantic? Not sure about this! The text is hidden on large screens, becomes the clicky title on mobile-->
    <h2 id="crumb-navigation" class="crumb-title">
      <span class="sr-only">Breadcrumb navigation: </span>Expertise <span class="sr-only">Section</span>
    </h2>
    
    <ol class="crumb">
      <li class="crumb_item home"><a href="#?">Home</a></li>
      <li class="crumb_item"><a href="#?">About</a></li>
      <li class="crumb_item active"><a href="#?">Expertise</a>
        <ol>
          <li class="crumb_item active"><a href="#?">Capital Markets</a>
            <ol>
              <li class="crumb_item"><a href="#?">By the Numbers</a></li>
              <!-- no link element on current page -->
              <li class="crumb_item current">Structured Products</li>
              <li class="crumb_item"><a href="#?">History</a></li>
            </ol>
          </li>
          <li class="crumb_item"><a href="#?">Investments</a></li>
        </ol>
      </li><!-- .active -->
      <li class="crumb_item"><a href="#?">Our Work</a></li>
      <li class="crumb_item"><a href="#?">Contact</a></li>
    </ol><!-- .crumb -->
  </nav>

  <h1>Page Title, Expertise</h1>
  <p>Page content! This is an example of a responsive breadcrumb navigation that can also behave as a neat sitemap tool. UX idea by <a href="https://codepen.io/Zinderfine/">@Zinderfine</a>, blogged about <a href="https://arleym.com/codepen-responsive-breadcrumbs/" target="_blank">Here</a></p>

              
            
!

CSS

              
                @charset "UTF-8";

/* Base and Resetty */
body {
  padding: 2em;
  font-family: sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0
}

/* Placeholder */
header {
  background: #ccc;
  padding: 1em 0;
  font-size: 3em;
  color: #222;
  text-align: center;
  margin-bottom: 0;
}

/* Crumbs - mobile first */
.crumb-title {
  padding: 1em;
  font-size: 1.2em;
  background: #ccc;
  cursor: pointer;
  margin-top: 1em;
  margin-bottom: 0;
}

.crumb-title:hover {
  background: #e4e4e4;
}

.crumb-title::before {
  content: "▾ ";
  display: inline-block;
  width: 15px;
  margin-right: 0.5em;
  transition: all 150ms ease-in 33ms;
  transform: rotate(-90deg);
}

.w-crumbs:focus-within .crumb-title::before,
.crumb-title.open::before {
  transform: rotate(0deg);
}

.crumb,
.crumb ol {
  padding-left: 0;
}

.crumb {
  transition: all 150ms ease-in 33ms;
  margin: 0;
  background: #fcfcfc;
  border: 1px solid #ccc;
  border-top: 0;
  max-height: 0px;
  overflow: hidden;
}

.crumb a,
.crumb .current {
  text-decoration: none;
  /* Transparent border only needed for focus borders */
  border: 2px solid transparent;
}

.crumb a:hover {
  text-decoration: underline;
}

.crumb a:focus {
  outline: 0;
  border-color: rgba(0, 0, 255, 0.2);
  border-radius: 2px;
  background-color: rgba(0, 0, 255, 0.05);
}

/* Mobile only */
@media (max-width: 37.9em) {

  .w-crumbs:focus-within .crumb,
  .open+.crumb,
  .crumb ol {
    max-height: 999px;
    list-style: none;
    display: flex;
    flex-flow: column nowrap;
  }

  .crumb a {
    display: block;
  }

  .crumb a:hover {
    background-color: #ccc;
  }

  /* Faux-indents - I want the hover to go full width */
  /* With Sass we can auto increment the depth */
  .crumb_item a,
  .crumb_item.current {
    padding: 0.5em 0.5em 0.5em 1em;
  }

  .crumb_item .crumb_item a,
  .crumb_item .crumb_item.current {
    padding-left: 2em;
  }

  .crumb_item .crumb_item .crumb_item a,
  .crumb_item .crumb_item .crumb_item.current {
    padding-left: 3em;
  }

}

/* Desktop */
@media (min-width: 38em) {

  .crumb {
    border: 0;
    max-height: initial;
    margin-top: 1em;
  }

  .crumb,
  .crumb ol {
    display: flex;
    flex-flow: row wrap;
  }

  .crumb_item:not(.home) {
    padding-left: 0.5em;
  }

  .crumb a,
  .crumb .current {
    padding: 2px;
  }

  .crumb a::after {
    content: " »";
  }

  .crumb-title,
  .crumb>li,
  .crumb>li li {
    display: none;
  }

  .crumb>:first-child,
  .crumb>.active,
  .crumb>.active .active,
  .crumb .active .current {
    display: inline-flex;
  }
}

              
            
!

JS

              
                const crumbTrigger = document.querySelector('.crumb-title');
crumbTrigger.addEventListener('click', function () {
  crumbTrigger.classList.toggle('open');
}); 
              
            
!
999px

Console