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

              
                <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: #fff; 

}

/*Floats each item to the left with padding of 14 & 16 px.
Removes the underline with text decoration = none.*/
.navBar a{
  float: left;
  color: grey;
  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