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

              
                <h1>

  Flex Menu</h1>
<div class="container">
  <div class="flex-box"></div>
  <div class="flex-box"></div>
  <div class="flex-box"></div>

  <div class="menu">
    <ul class="menu__list">
      <li class="menu__item">Home</li>
      <li class="menu__item">About</li>
      <li class="menu__item dropdown-holder dropdown-holder1">
        Widgets
        <div class="hover-box">
          <ul class="hover-box__list">
            <li class="hover-box__item">Big Widget</li>
            <li class="hover-box__item">Bigger Widgets</li>
            <li class="hover-box__item">Huge Widget</li>
          </ul>
        </div>

      </li>
      <li class="menu__item dropdown-holder">Kabobs
        <div class="hover-box">
          <ul class="hover-box__list">
            <li class="hover-box__item">Shiskabobs</li>
            <li class="hover-box__item">BBQ kabobs</li>
            <li class="hover-box__item">Summer Kabobs</li>
          </ul>
        </div>

      </li>
      <li class="menu__item">Contact</li>

    </ul>
  </div>

  <div class="toggle">
    <span class="toggle__span"></span>
    <span class="toggle__span"></span>
    <span class="toggle__span"></span>
  </div>

</div>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  font-family: "Work Sans", sans-serif;
}

h1 {
  position: absolute;
  top: 50%;
  transform: translate(0, -50%);
  color: #fff;
  font-weight: 700;
  font-size: 48px;
  z-index: 10;
  width: 100%;
  text-align: center;
  @media only screen and (max-width: 880px){
    font-size: 32px;
  }
}

.container {
  display: flex;
  height: 100vh;
  z-index: 5;
  &__open {
    .menu {
      display: block;
    }
  }
}

.container__open .toggle {
  &__span {
    &:nth-child(1) {
      top: 18px;
      transform: rotate(45deg);
    }
    &:nth-child(2) {
      background-color: transparent;
    }
    &:nth-child(3) {
      top: 18px;
      transform: rotate(-45deg);
    }
  }
}

.container__open .flex-box:nth-child(2) {
  flex: 0 0 0;
}

.flex-box {
  background-color: #004d40;
  flex: 0 1 50%;
  transition: 0.5s all ease-in-out;
  position: relative;
  z-index: 15;
}

.flex-box:nth-child(2) {
  flex: 1 0 100%;
  background-color: #333;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 56px;
  color: #fff;
  font-weight: 700;
  z-index: 1;
}

.container:hover.flex-box:nth-child(2) {
  flex: 0 0 0;
}

.menu {
  display: none;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0%;
  height: 100vh;
  color: #fff;
  transform: translateY(-100%);
  background-color: transparent;
  animation: 0.4s slideDown 0.25s forwards;
  z-index: 100;
  -webkit-backface-visibility: hidden;

  &__list {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    list-style: none;
    padding: 0;
    @media only screen and (max-width: 880px) {
      flex-direction: column;
    }
  }
  &__item {
    font-weight: 700;
    font-size: 44px;
    padding: 1rem;
    margin: 0 1rem;
    text-align: center;
    background: linear-gradient(
      120deg,
      transparent 0%,
      transparent 50%,
      #fff 50%
    );
    background-size: 240%;
    transition: 0.3s all ease-in-out;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    -webkit-backface-visibility: hidden;

    &:hover {
      background-position: 99%;
      color: #004d40;
    }

    @media only screen and(max-width: 1250px) {
      font-size: 36px;
    }

    @media only screen and (max-width: 1000px) {
      font-size: 28px;
    }
  }
}

.hover-box {
  background-color: #fff;
  color: green;
  display: none;
  animation: 0.6s fadeIn ease-in-out;
  position: absolute;
  color: #004d40;
  top: 100%;
  width: 100%;
  left: 0;
  border-top: 4px solid #004d40;
  backface-visibility: none;

  &__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  &__item {
    box-sizing: border-box;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    padding: 6px 12px;
    border-bottom: 2px solid #004d40;
    transition: 0.2s background;
    box-sizing: border-box;
    backface-visibility: none;
    &:hover {
      background-color: #a5d6a7;
    }
  }
  @media only screen and (max-width: 880px) {
    display: block;
    position: relative;
    width: auto;
    border-top: 2px solid #004d40;

    &__list {
      flex-direction: row;
    }
  }
}

.toggle {
  cursor: pointer;
  position: fixed;
  top: 2rem;
  left: 2rem;
  z-index: 10000;
  width: 40px;
  height: 40px;

  &__span {
    height: 3px;
    width: 100%;
    background-color: #fff;
    position: absolute;
    transition: 0.4s;
    &:nth-child(1) {
      top: 10px;
    }
    &:nth-child(2) {
      top: 19px;
    }
    &:nth-child(3) {
      top: 28px;
    }
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

              
            
!

JS

              
                // MUST REFRESH PAGE ON DIFFERENT VIEWPORT FOR HOVER EFFECTS

if ($(window).width() > 739) {
  $(".dropdown-holder").on("mouseenter", function(e) {
    $(".hover-box", this).slideDown("fast");
    $(".dropdown-holder").on("mouseleave", function(e) {
      $(".hover-box", this).slideUp("fast");
    });
  });
}

document.querySelector(".toggle").addEventListener("click", function() {
  document.querySelector(".container").classList.toggle("container__open");
});

              
            
!
999px

Console