octocatstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource
via CSS Lint

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource
via JS Hint

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Want a Run Button?

If active, the preview will update automatically when you change code.

HTML

            
              <nav>
  <ul class="top-nav">
    <li class="active"><a href="#">Home</a></li>
    <li><a href="#">About</a>
      <ul class="sub-nav">
        <li><a href="#">Item 1</a></li>
        <li><a href="#">Item 2</a></li>
      <li><a href="#">Item 3</a></li>
      <li><a href="#">Item 4</a></li>
    </ul>
  </li>
  <li><a href="#">Clients</a>
    <ul class="sub-nav">
      <li><a href="#">Item 1</a></li>
      <li><a href="#">Item 2</a></li>
      <li><a href="#">Item 3</a></li>
      <li><a href="#">Item 4</a></li>
    </ul>
  </li>
  <li><a href="#">Contact Us</a></li>
</ul>
</nav>
<div class="content">
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>  
</div>
            
          
!

CSS

            
              * {
  box-sizing:border-box;
  
}

nav, .content {
  max-width:960px;
  margin: 0 auto;
}

nav {
  margin-top:20px;
}

.top-nav {
  text-align:center;
  font-size:0;
}

.top-nav li {
  display:inline-block;
  width:25%;
  background: #292929;  
  position:relative;
}

.top-nav > li:hover,
.sub-nav > li:hover {
  color:white;
}

.top-nav > li.active > a {
  color:green;
}

.top-nav > li a {
  text-decoration:none;
  font-size:24px;
  line-height:1.5em;
  text-align:center;
  display:block;
  color:lightgrey;
}


.top-nav > li a {
  border-left: 1px solid black;
  border-right: 1px solid #3c3c3c;
  border-bottom: 1px solid black;
  border-top: 1px solid #3c3c3c;
}


.top-nav > li > a:hover,
.sub-nav > li > a:hover {
  color:red;
}

.sub-nav {
  position:absolute;
  width:100%;
  visibility:hidden;
  
}

.top-nav li:hover .sub-nav {
  visibility:visible;
  
}

.sub-nav > li {
  display:block;
  width:100%;
  position:relative;
}

.sub-nav > li a {
  border-bottom: 1px solid black;
  border-top: 1px solid #3c3c3c;
}
.sub-nav > li:first-child {
    border-top: none;
}
.sub-nav > li:last-child {
   border-bottom: none;
}

.content {
  height:250px;
  background:lightgrey;
  padding:10px;
}
            
          
!

JS

            
              
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console