I'm trying to make a stupid horizontal nav bar with a drop-down on some of the items. The way I decided to do it is just by putting the drop-down in a div tag. This is easily changeable, i just don't like to go heavy on the html side.
Basically I just want my drop down to work when you hover over the parent element. Additional css is going to be used to make it pretty and positioned better.
Here's my js:
var dropdown = $('.dropdown');
var parent = dropdown.parent();
$(parent).hover(
function () {
dropdown.css('display', 'block');
}
);
Here's my css:
div.nav {
text-align: center;
}
div.nav > ul > li {
margin-top: 15px;
text-align: center;
font-size: 1.25em;
}
div.nav > ul > li {
display: inline-block;
list-style-type: none;
}
div.nav a {
padding: 1em;
}
div.dropdown {
display: none;
background-color: black;
position: absolute;
}
Here's my html:
<div class="nav">
<ul>
<li><a href="index.html">Home</a></li>
<li>
<a href="game.html">Sample Game</a>
<div class="dropdown">
<a href="index.html">About it</a>
<br>
<a href="index.html">Game</a>
</div>
</li>
<li><a href="solutions.html">TP Solutions</a></li>
<li><a href="projects.html">Projects</a></li>
<li><a href="contact.html">Contact Me</a></li>
</ul>
<div class="clear"></div>