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

              
                <nav>
  <!--  This is the button to toggele the menu on mobile devices  -->
  <div id="hamburger">
    <div id="bar1"></div>
    <div id="bar2"></div>
    <div id="bar3"></div>
  </div>

  <!-- This is the list of menu items   -->
  <div class="navMenu">
    <ul>
      <li>Skills</li>
      <li>Portfolio</li>
      <li>Services</li>
      <li>Contact</li>
      <li>Resume</li>
    </ul>
  </div>
</nav>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Hide the menu to the side on mobile and not allow scrolling to the side */
html {
  overflow-x: hidden;
}

/* basic styles for the header component */
nav {
  width: 100%;
  padding: 20px;
}

/* Make nav menu items take full width allocated */
.navMenu ul {
  display: flex;
  justify-content: space-between;
}

.navMenu li {
  list-style: none;
  font-size: 1em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
}

.navMenu li:hover {
  color: blue;
}

/* Styles for the hamburger menu icon */
#hamburger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10;
}

#hamburger div {
  width: 22px;
  height: 2px;
  background-color: black;
  margin: 4px 0;
  transition: 0.5s;
}

#hamburger {
  display: none;
}

@media screen and (max-width: 768px) {
  #hamburger {
    display: block;
  }

  .navMenu {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    transform: translateX(100%);
    transition: 0.5s;
  }

  .navMenu ul {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
  }

  .navMenu li {
    color: white;
    padding: 15px 0;
  }
}

/* Extra utility classes to be added with JS */

.nav-active {
  transform: translateX(0);
}

#hamburger.toggle div {
  background-color: white;
}

.toggle #bar1 {
  transform: rotate(-45deg) translate(-5px, 4px);
}

.toggle #bar2 {
  opacity: 0;
}

.toggle #bar3 {
  transform: rotate(45deg) translate(-5px, -4px);
}

              
            
!

JS

              
                // Responsive hamburger menu demo by Paul Ehikhuemen
var hamburger = document.querySelector("#hamburger");
var nav = document.querySelector(".navMenu");
var navLinks = document.querySelectorAll(".navMenu li");

// close nav by clicking on list items
Array.from(navLinks).forEach((li) =>
  li.addEventListener("click", () => {
    if (hamburger.classList.contains("toggle")) {
      hamburger.classList.remove("toggle");
    }
    if (nav.classList.contains("nav-active")) {
      nav.classList.remove("nav-active");
    }
  })
);

// toggle nav on click of hamburger menu icon
hamburger.addEventListener("click", () => {
  nav.classList.toggle("nav-active");

  // burger animation
  hamburger.classList.toggle("toggle");
});

              
            
!
999px

Console