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 9097045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:00:48+00:00 2026-06-17T00:00:48+00:00

I have this CSS: #menuBar { /*width: 960px;*/ height: 35px; clear: both; } ul#nav

  • 0

I have this CSS:

#menuBar {
  /*width: 960px;*/
  height: 35px;
  clear: both;
}

ul#nav {
  float: left;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  background-color: #0068b4;
}

ul#nav li {
  display: inline;
}

ul#nav li a {
  float: left;
  line-height: 35px;
  color: #ffffff;
  text-decoration: none;
  margin: 0;
  padding: 0 30px;
  background-color: #0068b4;
}

/* APPLIES THE ACTIVE STATE TO PARENT*/
ul#nav .currentParent a, ul#nav li:hover > a  {
  color: #ffffff;
  text-decoration: none;
  background: #005899;
}

/* THE SUBMENU LIST HIDDEN BY DEFAULT */
ul#nav  ul {
  display: none;
}

/* WHEN THE FIRST LEVEL MENU ITEM IS HOVERED, THE CHILD MENU APPEARS */
ul#nav li:hover > ul {
  position: absolute;
  display: block;
  width: 97%;
  height: 35px;
  margin: 35px 0 0 0;
  background-color: #e0e0e0;
}

ul#nav li:hover > ul li a {
  float: left;
  line-height: 35px;
  color: #000000;
  text-decoration: none;
  margin: 0;
  padding: 0 30px 0 30px;
  background-color: #e0e0e0;
}

/* APPLIES THE ACTIVE STATE TO CHILD*/
ul#nav li ul li.currentChild a, ul#nav li:hover > ul li a:hover {
  color: #000000;
  text-decoration: none;
  background-color: #afafaf;
}

And this HTML:

<div id="menuBar">
    <ul id="nav">
    <li><a href="javascript: void;">Menu 1</a>
        <ul>
            <li><a href="menu1submenuitem1.html">Menu 1 Submenu item 1</a></li>
            <li><a href="menu1submenuitem2.html">Menu 1 Submenu item 2</a></li>
            <li><a href="menu1submenuitem3.html">Menu 1 Submenu item 3</a></li>
        </ul>
    </li>
    <li><a href="javascript: void;">Menu 2</a>
        <ul>
            <li><a href="menu2submenuitem1.html">Menu 2 Submenu item 1</a></li>
            <li><a href="menu2submenuitem2.html">Menu 2 Submenu item 2</a></li>
        </ul>
    </li>
    <li class="currentParent"><a href="javascript: void;">Menu 3</a>
        <ul>
            <li><a href="menu3submenuitem1.html">Menu 3 Submenu item 1</a></li>
            <li class="currentChild"><a href="menu3submenuitem2.html">Menu 3 Submenu item 2</a></li>
            <li><a href="menu3submenuitem3.html">Menu 3 Submenu item 3</a></li>
        </ul>
    </li>   
    </ul>
</div>

I’m using this to display a two level horizontal menu. What I want to achieve is that when an option from the second level is clicked I want the parent and the children itself to remain highlighted. To do this I’m actually building the HTML for the menu in the code behind of my ASP.net page and using the styles: currentParent and currentChild to highlight them. That’s working, what I’ve not been able to figure out is how to make the second level that contains the child that was clicked to stay visible. I’ve tried by adding display: none in a lot of places, but nothing is working. I’m wondering if somebody can help me with this and give some advise of the modifications I need to add to the CSS to achieve this?

EDIT 1:

I’ve completed the code and reviewed that it’s working (you can see it here: http://jsfiddle.net/cesarvinas/ZQWe7/). You can see in the HTML code that I’ve applied the class current Parent to parent menu Menu 3 and the class currentChild to submenu item Menu 3 Submenu item 2. With this, the parent and child are now highlighted. What I want in addition is that the row that contains the submenu items (the gray one): Menu 3 Submenu item 1, Menu 3 Submenu item 2, and Menu 3 Submenu item 3 remains visible.

As I explained in the main post, I have added code to the code behind of the ASP .net page to build the HTML up and assign the CSS classes when necessary.

Is there a way to have a CSS class that I can assign to the parent <li> (in the example, the Menu 3 parent) to keep its children visible?

EDIT 2

Thanks to the help I’ve received here, specially from 3dgoo, this is almost done. I’ve updated the example here: http://jsfiddle.net/cesarvinas/ZQWe7/5/. However, to make the submenu items that are not current to remain silver (and not blue as in 3dgoo example) I’ve had to create one more CSS class “.notselected” that I’m applying to those submenu items that are not selected. My question is: is there a way to achieve the same without having to add an extra CSS class? This is what I’ve done:

ul#nav li ul li.notselected a,
ul#nav li:hover > ul li a {
  float: left;
  line-height: 35px;
  color: #000000;
  text-decoration: none;
  margin: 0;
  padding: 0 30px 0 30px;
  background-color: #e0e0e0;
}

and the HTML:

<li class="currentParent"><a href="#">Menu 3</a>
    <ul>
        <li class="notselected"><a href="#">Menu 3 Submenu item 1</a></li>
        <li class="currentChild"><a href="#">Menu 3 Submenu item 2</a></li>
        <li class="notselected"><a href="#">Menu 3 Submenu item 3</a></li>
    </ul>
</li>   

I’ve tried with this in the CSS:

ul#nav li ul li a,
ul#nav li:hover > ul li a {
  float: left;
  line-height: 35px;
  color: #000000;
  text-decoration: none;
  margin: 0;
  padding: 0 30px 0 30px;
  background-color: #e0e0e0;
}

and removing the class="notselected" from the HTML, but it doesn’t work. Why is that?

Thanks.

  • 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-17T00:00:49+00:00Added an answer on June 17, 2026 at 12:00 am

    You can do this by using the following css selector ul#nav li.currentParent > ul like so:

    CSS

    ...
    ul#nav li.currentParent > ul, // Add this
    ul#nav li:hover > ul {
        position: absolute;
        display: block;
        width: 97%;
        height: 35px;
        margin: 35px 0 0 0;
        background-color: #e0e0e0;
    }
    ul#nav li:hover > ul { // And add these three lines
        z-index: 10;
    }
    ...
    

    Demo

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

Sidebar

Related Questions

I have this css code here .navigation{ width:100%; background-color:#7a7a7a; font-size:18px; } .navigation ul {
I have this CSS .menuPopup div { width: 100%; padding: 5px; } .menuClose {
I have got this css: <style type=text/css> #heading{ margin:auto; background-color: brown; } </style> and
I have this CSS style: span { font-family: Book Antiqua; clear: right; vertical-align: top;
I have this CSS declaration: .columns { width: 950px; font-family: verdana, arial; font-weight: normal;
i have this css code, and i want to shorten it. #one{ background: #6cab26;
I have this CSS. the property FILTER In class .crumb make my background and
I have this css: fieldset li { padding-bottom: 0em; } However, it wasn't behaving
i have this CSS code: h1 { font-size:22px; color:#341C12; font-weight:normal; font-style:italic; } .h1color h1{
I have this CSS style that does a rounded corners for div border, but

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.