I know I will be hissed at for asking a question like this, but I'm new to selectors and am struggling with hover effects for a child UL embedded in an existing UL.
The HTML:
<ul id="ctxMenuStock">
<li><a href="#ctxCMDCopy">Copy</a></li>
<li><a href="#ctxCMDReserve">Reserve/Outgoing</a></li>
<li><a href="#">Set Status <span style="font-family: Webdings">6</span></a>
<ul id="ctxMenuStockStatuses" runat="server"></ul>
</li>
</ul>
ctxMenuStockStatuses is populated by server code on page load.
The CSS:
#ctxMenuStock, #ctxMenuStock ul, #ctxMenuPending, #ctxMenuPending ul{
display:none;
margin:0;
padding:0;
list-style-type:none;
list-style-position:outside;
position:fixed;
line-height:1.5em;
}
#ctxMenuStock a:link, #ctxMenuStock hr, #ctxMenuStock a:active, #ctxMenuStock a:visited, #ctxMenuPending a:link, #ctxMenuPending hr, #ctxMenuPending a:active, #ctxMenuPending a:visited{
display:block;
padding:0px 5px;
color:#fff;
text-decoration:none;
background-color:#333;
}
#ctxMenuStock>li:hover ul, #ctxMenuStock>li:hover ul li, #ctxMenuStock>li:hover ul li a
{
color:#fff;
background-color:#333;
}
#ctxMenuStock>li:hover a, #ctxMenuPending>li:hover a{
background-color:#fff;
color:#333;
}
#ctxMenuStock ul li ul li a:hover, #ctxMenuPending ul li ul li a:hover{
background-color:#fff;
color:#333;
}
#ctxMenuStockStatuses li
{
color:#fff;
background-color:#333;
}
#ctxMenuStockStatuses li:hover
{
background-color:#fff;
color:#333;
}
#ctxMenuStock li, #ctxMenuPending li{
float:none;
position:relative;
}
#ctxMenuStock ul, #ctxMenuPending ul {
position:absolute;
display:none;
float:left;
}
#ctxMenuStock li ul a, #ctxMenuPending li ul a
{
width:12em;
margin: 0 0 0 4px;
float:left;
}
#ctxMenuStock ul ul, #ctxMenuPending ul ul{
top:auto;
}
#ctxMenuStock li ul ul, #ctxMenuPending li ul ul {
left:12em;
margin:0px 0 0 10px;
}
#ctxMenuStock li:hover ul ul, #ctxMenuStock li:hover ul ul ul, #ctxMenuStock li:hover ul ul ul ul{
display:none;
}
#ctxMenuStock li:hover ul, #ctxMenuStock li li:hover ul, #ctxMenuStock li li li:hover ul, #ctxMenuStock li li li li:hover ul{
display:block;
}
#ctxMenuPending li:hover ul ul, #ctxMenuPending li:hover ul ul ul, #ctxMenuPending li:hover ul ul ul ul{
display:none;
}
#ctxMenuPending li:hover ul, #ctxMenuPending li li:hover ul, #ctxMenuPending li li li:hover ul, #ctxMenuPending li li li li:hover ul{
display:block;
}
The menu is basically styled as a dark background with white text, but on hover this reverses. This works ok for the parent menu, but the child menu doesn't change and remains white on black.
I know some of this CSS is contradicting each other, but its becoming difficult to follow. I can't seem to find alot (if any) of working examples online of how to do this with sub-menus.
Can somebody please show me the best approach for this.
EDIT: As requested, JSFiddle example created: http://jsfiddle.net/KzhEP/ Although in my main project, the oncontextmenu attribute is attached to each row of my table server-side. I have mocked up a simple example, but for some reason i cannot get the right click functionality working on jsfiddle.