Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:47:10+00:00 2026-06-17T09:47:10+00:00

I know I will be hissed at for asking a question like this, but

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:47:11+00:00Added an answer on June 17, 2026 at 9:47 am

    It is diffcult to tell what you are wanting to achieve here, but you can try the following ~

    Delete the following css as it is overriding the nested black on white css changes:

    #ctxMenuStock>li:hover ul, #ctxMenuStock>li:hover ul li, 
    #ctxMenuStock>li:hover ul li a{
        color:#fff;
        background-color:#333;
    }
    

    Then change the CSS selector that provides the hover effect from:

    #ctxMenuStock>li:hover a, #ctxMenuPending>li:hover a{
        background-color:#fff;
        color:#333;
    }
    

    To:

    #ctxMenuStock li:hover > a, #ctxMenuPending li:hover > a{
        background-color:#fff;
        color:#333;
    }
    

    This way you are targeting all li elements in #ctxMenuStock and #ctxMenuPending no mattter of depth – but you only manipulate the child anchor tag of a hovered li element.

    Example: http://jsfiddle.net/embWK/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new and I know I will get beat down for this Question
I know this question has been asked before but I still haven't seen a
I know this will let the user retrieve the latest 10 posts from cocacola
I know i will get this exception when i try to modify or remove
I would like to know what will happen in the following hypothetical situation. Let's
I would like to know how will performance go when I instantiate multiple classes
Well..I am learning java now and I am curious to know will this yield
I would like to perform some request in mysql that i know will be
I wanted to know will pthread_detach halt the parent until the child thread terminates,
I have an ICollection that I know will only ever have one member. Currently,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.