I have a problem with a dropdown menu I am doing. Please check this screenshot out: http://img215.imageshack.us/img215/8449/hovermenu.png
This is the html code:
<ul class="topnav">
<li><a href="#">Home</a></li>
<li>
<a href="#" class="subnavkey">Tutorials</a>
<ul class="subnav">
<li><a href="#">Sub Nav Link</a></li>
<li><a href="#">Sub Nav Link</a></li>
</ul>
</li>
<li>
<a href="#" class="subnavkey">Resources</a>
<ul class="subnav">
<li><a href="#">Sub Nav Link</a></li>
<li><a href="#">Sub Nav Link</a></li>
</ul>
</li>
<li><a href="#">About Us</a></li>
<li><a href="#">Advertise</a></li>
<li><a href="#">Submit</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
And here is the jQuery code:
$(document).ready(function(){
$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)
$(".subnavkey").hover(function() { //When trigger is clicked...
//Following events are applied to the subnav itself (moving subnav up and down)
$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
$(this).parent().hover(function() {
}, function(){
$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
});
//Following events are applied to the trigger (Hover events for the trigger)
}).hover(function() {
$(this).addClass("subhover"); //On hover over, add class "subhover"
}, function(){ //On Hover Out
$(this).removeClass("subhover"); //On hover out, remove class "subhover"
});
});
Here is the CSS:
ul.topnav {
background: url(../images/topmenubg.png);
background-repeat: repeat-x;
border-radius:16px;
border-color:#a5a7a8;
list-style: none;
float: right;
font-size: 1.2em;
list-style-type:none;
text-align: left;
padding:0px;
margin-top:9px;
}
ul.topnav li {
float: left;
margin: 0;
padding: 10px;
position: relative; /*--Declare X and Y axis base for sub navigation--*/
border-color:#D9D9D9;
border-width:0px 1px 0px 0px;
border-style:solid;
display:block;
font-weight:500;
color:#333;
height:14px;
}
ul.topnav li:last-child{
border-width:0px;
}
ul.topnav li span { /*--Drop down trigger styles--*/
float: left;
}
ul.topnav li span.subhover {background-position: center bottom; cursor: pointer;} /*--Hover effect for trigger--*/
ul.topnav li ul.subnav {
list-style: none;
position: absolute; /*--Important - Keeps subnav from affecting main navigation flow--*/
left: 0; top: 35px;
background: #fff;
margin: 0; padding: 0;
display: none;
float: left;
width: 170px;
border: 1px solid #111;
}
ul.topnav li ul.subnav li{
margin: 0; padding: 0;
border-top: 1px solid #252525; /*--Create bevel effect--*/
border-bottom: 1px solid #444; /*--Create bevel effect--*/
clear: both;
width: 170px;
}
html ul.topnav li ul.subnav li a {
float: left;
width: 145px;
background: #fff;
padding-left: 20px;
}
html ul.topnav li ul.subnav li a:hover { /*--Hover effect for subnav links--*/
background: #fff;
}
As you can see in the screenshot, it only shows a little part of the first link in the "sub-menu"/"dropdown-menu". And as the HTML code shows, there are more links.
How can I do so it shows all the links?