I’m trying to create a very simple menu with submenus using only HTML and CSS (no javascript). Right now I have this code:
<ul id="main_ul>
<li id="hover_1">Item 1
<ul id="submenu_1>
<li>Subitem 1</li>
<li>Subitem 2</li>
</ul>
</li>
<li id="hover_2">Item 2
<ul id="submenu_2>
<li>Subitem 3</li>
<li>Subitem 4</li>
</ul>
</li>
</ul>
And here’s the CSS:
#main_ul li
{
display:inline;
}
#submenu_1
{
visibility:hidden;
}
#submenu_2
{
visibility:hidden;
}
#hover_1:hover #submenu_1
{
visibility:visible;
}
#hover_2:hover #submenu_2
{
visibility:visible;
}
Without the submenus in the code, the display:inline; property works fine, but with the submenus in the code it breaks. I want the normal menus, Item 1 and 2, to be on the same row even with the submenus there. What can I do to achieve this?
With this CSS it will work