The options in the drop-down menu appear to be stuck and remain in place

Can someone with expertise lend me a hand? I've been racking my brain over this issue, and while I feel like I'm on the right track, I just can't seem to make my sub-sub menu items drop down to the right on hover.

I suspect there might be conflicting or redundant CSS rules causing the problem. I've tried tweaking and adjusting various parts of the code, but nothing seems to work. I combined elements from two different menus to create this one, so I know there's room for simplification.

If anyone could take a look and point out where things are going wrong, that would be greatly appreciated. Specifically, I need the uls for Toy 1 and Toy 3 to drop down when hovered over. Thanks in advance!

HTML

<!-- drop menu-->  
 <ul id="menu">
  <li><a href="toys.aspx">TOYS</a>
   <div class="menu-container-1">      
     <ul class="column-1">       
      <li><a href=""><span>Toy 1</span></a>
        <ul>
          <li><a href="">sub menu basic 1</a></li>
        </ul>
      </li>  
      <li><a href="">Toy 2</a></li>
      <li><a href=""><span>Toy 3</span></a>
         <ul>
          <li><a href="">sub menu basic 3</a></li>
         </ul>
      </li>
      <li><a href="">Toy 4</a></li>        
    </ul>   
  </div>
  </li>
  </ul> 

And below is the corresponding CSS:

#menu li {
float:left;
display:block;
position:relative;
text-align:center;
padding:4px 18px;  
margin:0px 27px 0 0;
border:none; }
#menu li:hover {
border-width:0 0 0 1px;border-style:solid;border-color:#F1F7FC;  
padding:4px 18px 4px 17px;  
display:block; }

#menu li a {
font-family:Arial, Helvetica, sans-serif;
font-size:16px/1.8em;
color: #000;
display:block;
outline:0;
text-decoration:none;
font-weight:500;  }
#menu li:hover a {
color:#161616;   }
/* Additional menu container styles */

...
(additional CSS rules remain the same)
...

For further reference, here is a js-fiddle link: http://jsfiddle.net/tousif123/TfhLb/

Answer №1

Consider trying the following steps:

First, remove this code:

#menu ul li ul li {
    display: none;
}

Then, add this new code:

ul.column-1 li ul
{
display:none;
}

ul.column-1 li:hover ul
{
    display:block;
}

You can also check out a live demo on jsFiddle: http://jsfiddle.net/tousif123/brBj5/

Answer №2

Your block display selector is incorrect:

#menu ul li ul li ul li hover>* {display:block; }

The correct format should be:

#menu ul li:hover ul li { display: block; }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to insert my words within the boundary?

I am seeking assistance on inserting text within the border I created using an image. As I continue to add more text, I want it to display within the border as I type. Any guidance you can provide would be greatly appreciated. Thank you! li { list-sty ...

Troubles encountered with image referencing while generating a styleguide via kss-node

I'm currently utilizing the NodeJS implementation of KSS for my project. The file structure I am working with is as follows: styles (.scss files) public (compiled .css files) images (images & sprites) guide (auto-generated style ...

Tips for Identifying Different ID Values of HTML Elements with jQuery

Currently, I have two different divs on my webpage, each containing buttons and hidden fields. When I try to pass the value of the hidden field attached to the button in a jQuery function, I encounter an issue where clicking on the second div results in pa ...

Struggling with proper vertical alignment using Flexbox and achieving center alignment

I've been using JavaScript for displaying dynamic text and images, but I'm facing some formatting issues. Currently, I'm utilizing display: flex to position the text and image next to each other, but I'm struggling with horizontal alig ...

Is there a way to use JavaScript to alter the existing URL?

Currently, I am utilizing a select tag to allow users to choose the number of 'rows' displayed on the table. <%=select_tag :per_page, options_for_select([10,20,50,100]....some more code...., onchange => "if (this.value) {windows.location=& ...

Expanding the width of the containing div using CSS

I have a main container with multiple smaller divs inside it. None of these small divs have specified widths. I want the black div to expand and fill up the entire space, stretching all the way to the ABC div on the right. This only needs to work in Chr ...

Challenges with Table and <p> Spacing in HTML and CSS

My website is centered around tables. The body section of my site aligns with the bottom of the header nav bar. However, when I begin typing text in the body, it shifts down by a few pixels. Here are some examples: Before typing any text: After entering ...

Having trouble with the nth-child CSS property in Bootstrap?

My cards need some styling adjustments - specifically, I want the first and third card in each row to have a top margin of 50px. Strangely, this doesn't seem to work with Bootstrap, but it does with pure CSS. Is there a specific class in Bootstrap tha ...

Toggle the visibility of a div by clicking on another div in a

I have created a unique design where a div features a background image of a face, along with a paragraph, two buttons, and an input box inside it. While I know this question has been asked before, my scenario is slightly different. I want the div with the ...

Error in onchange event due to incorrect index variable

My goal is to add onchange events to select tags within a div that contains multiple tags. To achieve this, I am using a for loop to attach events to each tag. The purpose of these events is to update a select tag in another container by removing the "disa ...

How to use jQuery to maintain an image at the top of a div

Within my HTML, there is a primary root div element containing an image. <div id="root"> <img id="msg"/> </div> Using jQuery, I am able to prepend multiple div elements inside the main root div. However, the problem arises when these ...

Ways to display JSON in a structured format on an HTML page

Is there a way to display JSON in a formatted view on my html page? The JSON data is coming from a database and I want it to be displayed neatly like the following example: { "crews": [{ "items": [ { "year" : "2013", "boat" ...

The outcome of the Javascript Calculator is showing as "Undefined"

I've been attempting to create a calculator using JavaScript, but I'm facing an issue where the 'operate' function keeps returning Undefined, and I can't seem to figure out why. I suspect that the problem lies with the switch state ...

Tips for choosing multiple files with the Ctrl key in a list item element:

We have decided to create our own browsing functionality due to the limitations of the existing HTML browse feature. While using the HTML browse, we can only select multiple files by pressing the Ctrl key, and we want to replicate this feature in our custo ...

Tips for determining the actions of a node prior to its inception

Is there a way to automatically run scripts on specific elements after their creation? For example, using a jQuery plugin like autoresize to expand the height of a textarea. If I use $('.textarea').autosize(), only the current textareas will be a ...

How can I center one middle position for my inputs and have the span align to the left?

How can I center my input fields with all the spans aligned to the left? I would like the inputs to be centered on the page, with supporting spans aligned to the left or right of the input lane. I am utilizing some Bootstrap 4 classes for this layout. C ...

The use of the `/deep/` combinator in CSS has been phased out and is set to be completely removed

After updating my angular to version 4.0.0 and chrome to 62.0.3202.94, I encountered the following error message: [Deprecation] /deep/ combinator in CSS is deprecated and will be removed in M63, around December 2017. Refer to for more information. The ...

Calculate the frequency of tag_name occurrences on a webpage using Python and Selenium

Greetings! I am currently working with the following code snippet: for each in driver.find_elements_by_xpath(".//*[@id='ip_market" + market + "']/table/tbody") cell = each.find_elements_by_tag_name('td')[0] cell2 = each.find_el ...

What could be causing flexbox not to shrink to fit after wrapping its elements?

My goal is to create a flexbox with a maximum width that allows elements to wrap beyond that width without affecting the overall size of the flexbox's "row." The issue I am encountering is that when an element stretches beyond the maximum width and w ...

The functionality of the localStorage HTML5 feature is experiencing issues within the WebView on Samsung Android devices

I am currently facing an issue with my HTML5 application which I am wrapping with a WebView. In order to store and retrieve user input values between pages, I have been utilizing the localStorage feature in HTML5. Interestingly, this feature functions per ...