Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <body>
<header class="main-header">
  <div class="logo">
    <a href="">
      <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
        <path d="M12 14l9-5-9-5-9 5 9 5z"></path>
        <path d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z"></path>
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222"></path>
      </svg>
    </a>
  </div>
  <nav class="main-nav" data-handler="MainNavigation">
    <ul class="main-nav__primary" role="menubar">
      <li class="nav-item nav-item-1">
        <a class="nav-item-link" href="/item-1">Item 1</a>
      </li>
      <li class="nav-item nav-item-2">
        <a class="nav-item-link" href="/item-2">Item 2</a>
      </li>
      <li class="nav-item nav-item-3">
        <a class="nav-item-link" href="/item-3">Item 3</a>
      </li>
      <li class="nav-item nav-item-4">
        <a class="nav-item-link" href="/item-4">Item 4</a>
      </li>
      <li class="nav-item nav-item-5">
        <a class="nav-item-link" href="/item-5">Item 5</a>
      </li>
      <li class="nav-item nav-item-6">
        <a class="nav-item-link" href="/item-6">Item 6</a>
      </li>
      <li class="nav-item nav-item-7">
        <a class="nav-item-link" href="/item-7">Item 7</a>
      </li>
      <li class="nav-item nav-item-8">
        <a class="nav-item-link" href="/item-8">Item 8</a>
      </li>
      <li class="nav-item nav-item-9">
        <a class="nav-item-link" href="/item-9">Item 9</a>
      </li> 
      <li class="nav-item nav-item-10">
        <a class="nav-item-link" href="/item-10">Item 10</a>
      </li>
      <li class="nav-item main-nav-more-item" role="none">
        <button class="main-nav-more-item__button" type="button" aria-haspopup="true" aria-expanded="false">
          <span class="menu-text--lg">More</span>
          <span class="menu-text--lg--close">Less</span>
          <span class="menu-text--sm">Menu</span>
          <span class="menu-text--sm--close">Less</span>
        </button>
      </li>       
    </ul>
    <span></span>
  </nav>
  <nav class="secondary-nav">
    <ul class="main-nav__secondary" role="menubar">
      <li class="nav-item nav-item-1">
        <a class="nav-item-link" href="/item-1" tabindex="-1">Item 1</a>
      </li>
      <li class="nav-item nav-item-2">
        <a class="nav-item-link" href="/item-2" tabindex="-1">Item 2</a>
      </li>
      <li class="nav-item nav-item-3">
        <a class="nav-item-link" href="/item-3" tabindex="-1">Item 3</a>
      </li>
      <li class="nav-item nav-item-4">
        <a class="nav-item-link" href="/item-4" tabindex="-1">Item 4</a>
      </li>
      <li class="nav-item nav-item-5">
        <a class="nav-item-link" href="/item-5" tabindex="-1">Item 5</a>
      </li>
      <li class="nav-item nav-item-6">
        <a class="nav-item-link" href="/item-6" tabindex="-1">Item 6</a>
      </li>
      <li class="nav-item nav-item-7">
        <a class="nav-item-link" href="/item-7" tabindex="-1">Item 7</a>
      </li>
      <li class="nav-item nav-item-8">
        <a class="nav-item-link" href="/item-8" tabindex="-1">Item 8</a>
      </li>
      <li class="nav-item nav-item-1">
        <a class="nav-item-link" href="/item-1" tabindex="-1">Item 1</a>
      </li>
      <li class="nav-item nav-item-9">
        <a class="nav-item-link" href="/item-9" tabindex="-1">Item 9</a>
      </li> 
      <li class="nav-item nav-item-10">
        <a class="nav-item-link" href="/item-10" tabindex="-1">Item 10</a>
      </li>      
    </ul>
  </nav>
  <div class="search">
    <form id="js-search-form" class="search-form" action="">
      <div class="search-input-wrapper">
        <input id="js-search-input" class="input search-input" inputmode="search" type="search" name="q" placeholder="Search articles..." aria-label="Search articles">
          <a id="js-search-clear-button" class="search-clear-button" tabindex="-1" role="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15.35 15.36" width="16" height="16" tabind="-1"><title>Clear Search</title><path fill="#e33b2a" d="M8.38 11.41c-.5-.5-.78-.52-1.33.0l-3.05 3.08c-1.18 1.18-1.7 1.18-3-.16s-1.18-2-.18-3l3.18-3.19a.69.69.0 0 0-.07-1.14l-3-3c-1-1-1.13-1.81.0-3s1.9-1.21 3.13.0l2.94 3a.66.66.0 0 0 1.11.0c.63-.65 2.49-2.51 3.28-3.35a1.46 1.46.0 0 1 2.3-.15c.24.24.47.42.89.84.86.86.94 1.57.05 2.46l-3.27 3.26c-.36.34-.52.58-.16.94l3.27 3.27c1.1 1.1 1.23 1.7.05 2.88l-.58.58a1.59 1.59.0 0 1-2.46-.21z"></path></svg></a>
        </input>
      </div>
    </form>
  </div>
</header>
</body>
              
            
!

CSS

              
                *,
::after,
::before {
  box-sizing: border-box;
}

html {
  line-height: 1.15;
}

body {
  margin: 0;
  background-color: blueviolet;
  color: #333;
  font-family: sans serif;
  font-size: calc(0.35842vw + 0.95296em);
}

::placeholder {
  color: #666;
}

::selection {
  background: #b3d4fc;
  text-shadow: none;
  color: black;
}

ul {
  max-width: 100%;
}

li {
  line-height: calc(1.5em + 0.2vw);
  word-break: break-word;
}

a {
  transition: color .1s ease-out;
  text-decoration: none;
  text-shadow: 3px 0 #fff, 2px 0 #fff, 1px 0 #fff, -1px 0 #fff, -2px 0 #fff,
    -3px 0 #fff;
}

button {
  margin: 0;
  cursor: pointer;
  text-transform: none;
  font: inherit;
  -webkit-appearance: button;
}

[type='search'] {
  outline-offset: -2px;
  -webkit-appearance: textfield;
}

.main-header {
  display: grid;
  position: relative;
  grid-template-columns: min-content minmax(140px, 2fr) 0 minmax(100px, 350px);
  align-items: center;
  justify-content: flex-start;
  column-gap: 10px;
  transition: all 0.4s ease-in;
  z-index: 2;
  background: blue;
  padding: 1rem 2em;
}

.logo {
  position: relative;
  z-index: 0;
  width: 3em;
  line-height: 0;
  font-size: 1em;

  a {
    display: block;
    outline: 0;
    background: 0 0;
    padding: 0;
    text-shadow: none;
    color: white;
  }
}

.main-nav {
  display: block;
  position: relative;
  grid-column: auto;
  margin-left: 1em;
  min-width: 0;
  color: #fff;
  font-size: 1.05em;

  &__primary {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    margin: 0;
    padding: 0;
    width: 100%;
    min-width: 0;
    list-style: none;
    color: inherit;
  }

  &-more-item {
    position: relative;
    margin-left: 0.35em;
    width: 145px;

    &__button {
      display: flex;
      position: relative;
      align-items: center;
      justify-content: space-around;
      border: 1px solid rgba(0, 0, 0, 0.05);
      border-radius: 11px;
      box-shadow: 0 13px 27px -15px rgba(50, 50, 93, 0.25),
        0 8px 16px -8px rgba(0, 0, 0, 0.3),
        0 -6px 16px -6px rgba(0, 0, 0, 0.025);
      background-color: rgba(0, 0, 0, 0.2);
      padding: 0.35em 0.5rem 0.35em 1rem;
      line-height: 1;
      white-space: nowrap;
      color: inherit;

      &::after {
        content: '';
        display: block;
        margin-left: 0.4em;
        background-image: url(https://www.smashingmagazine.com/images/icons/menu-cat.svg);
        background-position: center center;
        background-repeat: no-repeat;
        width: 30px;
        height: 30px;
      }

      &:hover,
      &:focus {
        background-color: rgba(0, 0, 0, 0.3);
      }

      .menu-text--lg--close,
      .menu-text--sm,
      .menu-text--sm--close {
        display: none;
      }
    }
  }
}

.nav-item {
  display: flex;
  flex-grow: 0;
  align-items: center;
  margin-bottom: 0;
  background: 0 0;
  padding-left: 0;
  text-shadow: none;
  color: inherit;
  font-weight: 700;

  &-link {
    background: 0 0;
    padding: 0.35em 0.9rem;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    color: inherit;

    &:hover,
    &:focus {
      outline-width: 0;
      border-radius: 11px;
      background-color: rgba(0, 0, 0, 0.15);
    }
  }
}

.secondary-nav {
  display: block;
  position: relative;
  grid-row: auto;
  grid-column: auto;
}

.main-nav__secondary {
  display: none;
  position: absolute;
  top: 0;
  left: -80px;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  transform: translate(-50%, 0);
  margin: 0;
  border-radius: 11px;
  box-shadow: 0 13px 27px -5px rgba(50, 50, 93, 0.25),
    0 8px 16px -8px rgba(0, 0, 0, 0.3), 0 -6px 16px -6px rgba(0, 0, 0, 0.025);
  background: #fff;
  padding: 14px 20px 10px 10px;
  min-width: 180px;
  max-width: unset;
  height: auto;
  color: blue;

  &:before {
    content: '';
    display: block;
    position: absolute;
    top: 1px;
    left: 50%;
    transform: translate(-50%, -100%);
    border-right: 15px solid transparent;
    border-bottom: 15px solid #fff;
    border-left: 15px solid transparent;
    width: 0;
    height: 0;
  }
}

.js-show-secondary {
  display: flex;
  top: 50px;
}

.search-input-wrapper {
  position: relative;
}

.search-input {
  transition: all 0.2s ease-in-out;
  border-radius: 11px;
  box-shadow: 0 13px 27px -5px rgba(50, 50, 93, 0.25),
    0 8px 16px -8px rgba(0, 0, 0, 0.3), 0 -6px 16px -6px rgba(0, 0, 0, 0.025);
  background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgaGVpZ2h0PSIyNHB4IiB3aWR0aD0iMjRweCI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJsaW5lYXItZ3JhZGllbnQiIHgxPSIyMi4zMSIgeTE9IjIzLjYyIiB4Mj0iMy43MyIgeTI9IjMuMDUiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiNlOTM3MjIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNmODZmMjUiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48dGl0bGU+TWFnbmlmaWVyPC90aXRsZT48cGF0aCBmaWxsPSJ1cmwoI2xpbmVhci1ncmFkaWVudCkiIGQ9Ik0yMy4zMyAyMC4xbC00LjczLTQuNzRhMTAuMDYgMTAuMDYgMCAxIDAtMy4yMyAzLjIzbDQuNzQgNC43NGEyLjI5IDIuMjkgMCAxIDAgMy4yMi0zLjIzem0tMTcuNDgtNS44NGE1Ljk0IDUuOTQgMCAxIDEgOC40MiAwIDYgNiAwIDAgMS04LjQyIDB6Ii8+PC9zdmc+);
  background-position: 0.75em 50%;
  background-repeat: no-repeat;
  background-size: 22px auto;
  padding-top: 1rem;
  padding-bottom: 1rem;
  padding-left: calc(22px + 0.75em + 0.75em);
  font-size: calc(1em + 0.1vw);
  font-weight: 700;

  &:hover {
    box-shadow: 0 30px 60px -12px rgba(50, 50, 93, 0.25),
      0 18px 36px -18px rgba(0, 0, 0, 0.3),
      0 -12px 36px -8px rgba(0, 0, 0, 0.025);
  }
}

.input {
  display: block;
  outline: 0;
  border: none;
  background-color: #fff;
  width: 100%;
  color: #333;
}

.search-clear-button {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translate(-25%, -50%);
  transition: opacity 0.2s ease-out;
  opacity: 0;
  border: none;
  background: 0 0;
  padding: 0.5em;
}

svg:not(:root) {
  overflow: hidden;
}

.nav-item-1,
.nav-item-10,
.nav-item-11,
.nav-item-2,
.nav-item-3,
.nav-item-4,
.nav-item-5,
.nav-item-6,
.nav-item-7,
.nav-item-8,
.nav-item-9 {
  display: none;
}
.main-nav__secondary .nav-item-1,
.main-nav__secondary .nav-item-10,
.main-nav__secondary .nav-item-11,
.main-nav__secondary .nav-item-2,
.main-nav__secondary .nav-item-3,
.main-nav__secondary .nav-item-4,
.main-nav__secondary .nav-item-5,
.main-nav__secondary .nav-item-6,
.main-nav__secondary .nav-item-7,
.main-nav__secondary .nav-item-8,
.main-nav__secondary .nav-item-9 {
  display: flex;
}

@media (min-width: 42.9375em) {
  .nav-item-1 {
    display: flex;
  }

  .main-nav__secondary .nav-item-1 {
    display: none;
  }
}

@media (min-width: 52.5em) {
  .nav-item-2 {
    display: flex;
  }

  .main-nav__secondary .nav-item-2 {
    display: none;
  }
}
@media (min-width: 56.5625em) {
  .nav-item-3 {
    display: flex;
  }
  .main-nav__secondary .nav-item-3 {
    display: none;
  }
}
@media (min-width: 65.625em) {
  .nav-item-4 {
    display: flex;
  }
  .main-nav__secondary .nav-item-4 {
    display: none;
  }
}
@media (min-width: 71.875em) {
  .nav-item-5 {
    display: flex;
  }
  .main-nav__secondary .nav-item-5 {
    display: none;
  }
}
@media (min-width: 89.0625em) {
  .nav-item-6 {
    display: flex;
  }
  .main-nav__secondary .nav-item-6 {
    display: none;
  }
}
@media (min-width: 100em) {
  .nav-item-7 {
    display: flex;
  }
  .main-nav__secondary .nav-item-7 {
    display: none;
  }
}
@media (min-width: 112.1875em) {
  .nav-item-8 {
    display: flex;
  }
  .main-nav__secondary .nav-item-8 {
    display: none;
  }
}
@media (min-width: 128.125em) {
  .nav-item-9 {
    display: flex;
  }
  .main-nav__secondary .nav-item-9 {
    display: none;
  }
}
@media (min-width: 171.25em) {
  .nav-item-10 {
    display: flex;
  }
  .main-nav__secondary .nav-item-10 {
    display: none;
  }
  .main-nav__primary {
    justify-content: flex-start;
  }
  .nav-item {
    padding: 0 0.65em;
  }
}

              
            
!

JS

              
                var moreNavBtn = document.querySelector('.main-nav-more-item__button');
var secondaryNav = document.querySelector('.main-nav__secondary');

moreNavBtn.addEventListener('click', function() {
  secondaryNav.classList.toggle('js-show-secondary');
})
              
            
!
999px

Console