Pen Settings



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


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


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.


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.


  <nav id="main-nav">
    <a class="logo" href="/">
      <img src="" alt="Our professional logo (ideally an svg!)" />
    <div class="dropdown-link-container">
      <a href="/about">About Us</a>
      <a href="/work">Our Work</a>
      <a href="/work">Contact Us</a>
    <button class="mobile-dropdown-toggle" aria-hidden="true">


                /* Yes, we wrapped our nav in a header tag.
This allows us to add a background to the nav bar without 
cutting off on our max-width property.
To see what I mean, try moving this background to the nav element
header {
  background: lightblue;

nav {
  max-width: 1200px;
  display: flex;
  align-items: center;
  margin: auto;

.logo {
  margin-right: auto;

.dropdown-link-container > a {
  margin-left: 20px;

.mobile-dropdown-toggle {
  display: none;

@media (max-width: 768px) {
  .mobile-dropdown-toggle {
    z-index: 1;

  .mobile-dropdown-toggle {
    display: initial;

  .dropdown-link-container {
    /* first, make our dropdown cover the screen */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100vh;
    /* fix nav height on mobile safari, where 100vh is a little off */
    height: -webkit-fill-available;

    /* then, arrange our links top to bottom */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;

    /* add margins and padding to taste */
    margin: 0;
    padding-left: 7vw;
    padding-right: 7vw;

    background: lightblue;
    z-index: 0;

    opacity: 0;
    transform: translateY(-100%);
    transition: transform 0.2s, opacity 0.2s;

  nav.dropdown-opened > .dropdown-link-container {
    opacity: 1;
    transform: translateY(0);

/* this stuff isn't super important */
html {
  font-family: sans-serif;

body {
  margin: 0;



                const navElement = document.getElementById("main-nav");
const dropdownEl = document.querySelector(".dropdown-link-container");

document.addEventListener("click", (event) => {
  if ("mobile-dropdown-toggle")) {

document.addEventListener("click", (event) => {
  // if we clicked on something inside our dropdown...
  if (dropdownEl.contains( {