I've been struggling to create a website with a dropdown menu. Despite following various guides and searching for solutions, the menu is behaving strangely. I've tried numerous tactics, so some lines of code may be unnecessary.
The submenu is appearing next to the main menu rather than underneath it.
Is there anyone who can assist me with this issue? Thanks in advance!
HTML:
<div id="menu">
<ul>
<li class="current_page_item"><a href="#" accesskey="1" title="">Home</a></li>
<li><a href="pagina2.html" accesskey="2" title="">Hardware</a>
<ul>
<li><a href="pagina2.html" accesskey="69" title="">Hardware2</a></li>
<li><a href="pagina2.html" accesskey="70" title="">Hardware3</a></li>
</ul></li>
<li><a href="#" accesskey="3" title="">About Us</a></li>
<li><a href="index_oud.html" accesskey="4" title="">sjabloon</a></li>
<li><a href="#" accesskey="5" title="">Contact Us</a>
</li>
</ul>
</div> <!-- menu -->
CSS:
#menu
{
position: absolute;
right: 0;
}
#menu ul
{
display: inline-block;
line-height: 1em;
position: relative; /* side by side*/
right: 0;
top: 2em;
list-style: none;
/*display: inline-table;*/
}
/*
#menu ul: after
{
content: "";
clear: both;
display: inline-block;
}*/
#Menu ul ul {
display: none;
}
/*
#Menu ul li:hover > ul
{
display: inline-block;
}
*/
#menu ul li
{
float: left; /* on same line */
margin-left: 0.50em;
padding: 1em 1.5em;
letter-spacing: 0.20em;
font-size: 0.90em;
font-weight: 600;
text-transform: uppercase;
color: #OOC;
outline: 0;
}
#menu ul li:hover {
background: #00F;
}
#menu ul li:hover a {
color: #FFF;
}
#menu ul li a /*#menu ul li span*/
{
display: inline-block
margin-left: 0.50em;
letter-spacing: 0.20em;
text-decoration: none; /* no underline*/
font-size: 0.90em;
font-weight: 600;
text-transform: uppercase;
outline: 0;
color: #OOC;
}
#menu ul ul /* submenu*/
{
background: #00F;
top: 100%;
padding: 0;
position: absolute;
visibility: hidden;
}
#menu ul:hover ul
{
visibility:visible;
}
#menu ul ul li
{
float: none; /*one below the other */
border-top: 1px solid #CCCCCC;
border-bottom: 1px solid #CCCCCC;
position: relative;
color: #FFF;
}