<!-- Use this navigation div as your menu bar div -->
<div class="navigation">
<ul class="nav">
<li> <a href="#">Home</a>
</li>
<li> <a href="#">Services</a>
<ul>
<li><a href="#">Consulting</a>
</li>
<li><a href="#">Sales</a>
</li>
<li><a href="#">Support</a>
</li>
</ul>
</li>
<li> <a href="#">About Us</a>
<ul>
<li><a href="#">Company</a>
</li>
<li><a href="#">Mission</a>
</li>
<li><a href="#">Contact Information</a>
</li>
</ul>
</li>
</ul>
</div>
CSS
.nav {
margin: 0px;
padding: 0px;
list-style: none;
}
.nav li {
float: left;
width: 160px;
position: relative;
}
.nav li a {
background: #333;
color: #fff;
display: block;
padding: 7px 8px;
text-decoration: none;
border-top: 1px solid red;
}
.nav li a:hover {
color: #069;
}
/*=== submenu ===*/
.nav ul {
display: none;
position: absolute;
margin-left: 0px;
list-style: none;
padding: 0px;
}
.nav ul li {
width: autopx;
float: left;
}
.nav ul a {
display: block;
height: 15px;
padding: 7px 8px;
color: #fff;
text-decoration: none;
border-bottom: 1px solid #222;
}
.nav ul li a:hover {
color: #069;
}
JavaScript
$(document).ready(
function () {
$('.nav li').hover(
function () { //appearing on hover
$('ul', this).fadeIn();
},
function () { //disappearing on hover
$('ul', this).fadeOut();
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.