Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <nav role="navigation" id="nav">
              <input class="trigger" type="checkbox" id="mainNavButton">
              <label for="mainNavButton" onclick>Menu</label>
              <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">About Us</a>
                    <ul>
                      <li><a href="#">Sub Nav Item</a></li>
                      <li><a href="#">Sub Nav Item</a>
                        <ul>
                          <li><a href="#">Sub Sub Nav Item</a></li>
                          <li><a href="#">Sub Sub Nav Item</a></li>
                          <li><a href="#">Sub Sub Nav Item</a></li>
                          <li><a href="#">Sub Sub Nav Item</a></li>
                        </ul>
                      </li>
                      <li><a href="#">Sub Nav Item</a></li>
                      <li><a href="#">Sub Nav Item</a></li>
                    </ul>
                </li>
                <li><a href="#">Products</a></li>
                <li><a href="#">Blog</a></li>
                <li><a href="#">Specials</a></li>
                <li><a href="#">Contact Us</a></li>
              </ul>
              </ul> 
            </nav>

<h1>Responsive Flexbox Nav with :checked hack</h1>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestiae, dignissimos, distinctio consequatur eos optio recusandae maiores quidem possimus tempora esse reiciendis velit ut consequuntur architecto hic soluta deleniti fugit explicabo.</p>
            
          
!
            
              $primaryColor: #021320; // dark blue
$secondaryColor: #0F9962; // green
$tertiaryColor: #005292; // light blue

$flex_nav_hoverColor:darken($secondaryColor,5%);
$flex_nav_borderColor: darken($secondaryColor,10%);
$flex_nav_linkColor: white;
$flex_nav_hotdogsColor: white;

$flex_nav_subNavWidth: 12.5em;
$flex_nav_breakpoint: 48em;

body { 
  margin:25px;
  -webkit-animation: bugfix infinite 1s; /* needed for checkbox hack */
  background:$primaryColor;
}
@-webkit-keyframes bugfix { from {padding:0;} to {padding:0;} } /* needed for checkbox hack */

h1, p {
    color:white;
}

#nav {
  position:relative;
  
  ul {
    display:none;
    width:100%;
    list-style:none;
    margin:0px;
    padding:0px;
    
    li {
      a {
        display:block;
        padding:1em;
        background:$secondaryColor;
        color:$flex_nav_linkColor;
        text-decoration:none;
        border-right:1px solid $flex_nav_borderColor;
        &:hover {
          background:$flex_nav_hoverColor;
        }
      }
      &:last-of-type {
        a {
          border-right:0px;
        }
      }
      // 2nd level
      ul {
        li {
          a {
            padding-left:1.5em;
          }
          ul {
            li {
              a {
                padding-left:3.125em;
              }
            }
          }
        }
      }

    } // li
    
  } // ul 
  
  input.trigger {
    position: absolute;
    top: -9999px;
    left: -9999px;
    &:checked ~ ul,&:checked ~ ul li ul {
      display:block !important;
      @media (min-width:$flex_nav_breakpoint){
        /* older flexbox */
        display: -webkit-box;
        display: -moz-box;
        display: box;
        -webkit-box-orient: horizontal;
        -moz-box-orient: horizontal;
        box-orient: horizontal;
      
        /* newer flexbox */
        display: flex;
        flex-direction: row;
      }
    }
  }
  label {
    position:relative;
    display:block;
    min-height:2em;
    padding:.45em;
    font-size:1.1em;
    margin:0;
    cursor:pointer;
    background:$tertiaryColor;
    line-height: 2em;
    color:lighten($primaryColor,80%);
  }
    
  label:after {
    position: absolute;
    right: 1em;  
    top: .2em; 
    content:"\2261";
    font-size:1.8em;
    color:$flex_nav_hotdogsColor;
  }
  
  @media(min-width:$flex_nav_breakpoint){
    ul {
      /* older flexbox */
      //display:block;
      display: -ms-flexbox;
      flex-direction: -ms-row;
      display: -webkit-box;
      display: -moz-box;
      display: box;

      -webkit-box-orient: horizontal;
      -moz-box-orient: horizontal;
      box-orient: horizontal;
      
      /* newer flexbox */
      display: flex;
      flex-direction: row;
      
      li {
        position:relative;
        text-align: center;
        
        /* older flexbox */
        -ms-flex: 1;
        -webkit-box-flex: 1;
        -moz-box-flex: 1;
        box-flex: 1;
        
        /* newer flexbox */
        flex: 1;

        // 2nd level
        ul {
          display:none !important;
          position:absolute;
          top:3.0625em;
          left:0;
          display:block;
          width:$flex_nav_subNavWidth;
          z-index:200;
          li {
            text-align:left;
            ul {
              z-index: 300;
              top:0px;
              left: ($flex_nav_subNavWidth - .1);
              li {
                a {
                  padding-left:30px !important;
                }
              }
            }
          }
        } // ul 2nd level

        &:hover > ul {
          display: block !important;
        }

      } // li 
    } // ul
    label {
      display:none;
    }
  } // breakpoint

} // nav

            
          
!
            
              /* 

Support: IE10+, FF28+

Checkbox hack:
http://timpietrusky.com/advanced-checkbox-hack 

Polyfill for old IE:
http://flexiejs.com/

Warning: Not super accessible - just for fun


*/
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console