I am encountering an issue with a dropdown menu I have been working on. Take a look at this screenshot for reference:
Below is the snippet of 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>
Moreover, here is the jQuery code snippet:
$(document).ready(function(){
$("ul.subnav").parent().append("<span></span>"); //Adds drop down trigger when JavaScript enabled
$(".subnavkey").hover(function() {
$(this).parent().find("ul.subnav").slideDown('fast').show();
$(this).parent().hover(function() {
}, function(){
$(this).parent().find("ul.subnav").slideUp('slow');
});
}).hover(function() {
$(this).addClass("subhover");
}, function(){
$(this).removeClass("subhover");
});
});
Lastly, let's take a look at the CSS styling:
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;
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 {
float: left;
}
ul.topnav li span.subhover {background-position: center bottom; cursor: pointer;}
ul.topnav li ul.subnav {
list-style: none;
position: absolute;
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;
border-bottom: 1px solid #444;
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 {
background: #fff;
}
Upon reviewing the screenshot, it appears that only a portion of the first link in the "sub-menu"/"dropdown-menu" is visible. Given the HTML structure provided, how can I ensure all links are displayed correctly?