Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <div class="navBar" id="mainNavBar">
  <a href="#home">Home</a>
  <a href="#service">Services</a>
  <a href="#about">About Us</a>
  <a href="#contact">Contact</a>
  <a href="javascript:void(0);" class="icon" onClick="openDrawerMenu()">&#9776;</a>
  <!--&#9776; is the code for the 3 line menu button-->
</div>
              
            
!

CSS

              
                .navBar{
  background-color: #009cde; 
  overflow: hidden;
}

/*Floats each item to the left with padding of 14 & 16 px.
Removes the underline with text decoration = none.*/
.navBar a{
  float: left;
  color: white;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
  font-family: Tahoma;
}

/*Background color change during hover state*/
.navBar a:hover{
  background-color: white;
  color: #009cde;
}

/*Hides the menu Icon which will show when the nav needs to be responsive*/
.navBar .icon{
  display: none;
}

/*Set your custom screen width here replacing 700*/
@media (max-width: 700px){
/*Ignores the first link (which is Home) in the div and       applies 'display = none' to everything else.   Basically hiding everything but Home*/
  .navBar a:not(:first-child){
    display: none;
  }
/*Brings the menu icon into view and floats it to the right*/
  .navBar a.icon{
    display: block; float: right;
  }
  
/*The navBar class will be changed to 'navBar responsive' using JS. This chunk of CSS makes the menu icon stay where it is by making the position absolute within it's parent 'right top corner'. Without this, the icon will get kicked around when the items are collapsed and expanded*/
  .navBar.responsive {
    position: relative;
  }
  .navBar.responsive a.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  
/*Removes the originally set float and brings them to view*/
  .navBar.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
}

              
            
!

JS

              
                function openDrawerMenu(){
  var x = document.getElementById("mainNavBar");
  if (x.className === "navBar"){
    x.className += " responsive";
  } else {
    x.className = "navBar";
  }
}
              
            
!
999px

Console