Occasional issue with the drop down menu not appearing correctly

I'm experiencing some difficulties with displaying a dropdown menu.

Check out the fiddler link for reference: http://jsfiddle.net/GxrSk/

Below is the simplified HTML code:

 <nav>
       <ul id="top-menu">
       <li class="parent">
            <a href="#">MENU ITEM</a>
            <ul class="sub-menu">
                 <li><a href="#">ITEM 1</a></li>
                 <li><a href="#">ITEM 2</a></li>
            </ul>
       </li>
       </ul>
</nav>

The accompanying CSS snippet:

ol, ul {
    list-style: none;
    padding:0px;
    margin:0px;
}


nav { margin-top: 28px; }

#top-menu li { position: relative; }

#top-menu > li { display: inline-block; margin-left: 40px; }

#top-menu li a { font-family: "Ubuntu Condensed", sans-serif; color: #000; font-size: 16px; text-transform: uppercase; }

ul.sub-menu { display: none; top: 26px; position: absolute; min-width: 137px; z-index: 9999; }

ul.sub-menu > li > a { text-align: center; display: block; }

#top-menu li:hover > ul.sub-menu { display: block; }

The issue I'm encountering is that sometimes the menu functions properly, while other times it seems to disappear when trying to access it.

If my explanation is unclear, feel free to ask questions in the comments below.

Answer №1

Adjust the top to become padding on the top.

padding-top: 20px;

Answer №2

attempt to create ul.sub-menu { top:20px; }

ol, ul {
    list-style: none;
    padding:0px;
    margin:0px;
}

nav { margin-top: 28px; }

#top-menu li { position: relative; }

#top-menu > li { display: inline-block; margin-left: 40px; }

#top-menu li a { font-family: "Ubuntu Condensed", sans-serif; color: #000; font-size: 16px; text-transform: uppercase; }

ul.sub-menu { display: none; top: 20px; position: absolute; min-width: 137px; z-index: 9999; }

ul.sub-menu > li > a { text-align: center; display: block; }

#top-menu li:hover > ul.sub-menu { display: block; }

Answer №3

Continue adjusting the top-value in ul.sub-menu until it functions properly.

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

Tips for displaying content in a stacked format when hovering, similar to a list item (<li>), using jquery/javascript

I am attempting to display different content on hover over text, specifically listing various HTTP error codes. My setup includes 3 icons and text that will reveal specific content based on the text hovered over: success error blocked Below is the JS cod ...

Utilizing Next.js - Implementation of a unique useThemeMode hook to efficiently manage theme preferences stored in the browser's localStorage, seamlessly integrating with toggleTheme

For a while now, I've been trying to figure out how to toggle my favicon based on the theme logic of my application and the current theme state stored in localStorage. My approach involves using CSS variables and data attributes applied to the html bo ...

Unsubscribe from the Event Listener in Node.js

In light of this inquiry (linked here), can the Listener be eliminated from within the callback function? To illustrate: let callback = function(stream) { if(condition) performAction(); else server.removeListener('connection', cal ...

Upgrading the import package alias from 'angular2' to '@angular'

Is there a way to update the package alias for import purposes? I am trying to utilize ng2-bootstrap, which requires @angular/core, but I have been referencing it as angular2/core. This mismatch is causing my screen to crash! ...

Incorrect implementation of Bootstrap CSS in Jade template

Currently, I am leveraging Express to construct a website. However, there seems to be an issue with my jade template not displaying the bootstrap grid system accurately. Despite double-checking that my app path is correctly set through app.use(express.stat ...

Indentation differences between PHP and JavaScript

It's interesting to observe the different indentation conventions in various programming languages. Recently, I came across a code snippet from the PHP manual that caught my attention: switch ($i) { case "apple": echo "i is apple"; ...

I am unable to retrieve information from Firebase in Vue

Currently, I am following a tutorial on YouTube to enhance my knowledge about storing data in Firebase and then utilizing it in a Vue application. (You can watch the tutorial at this link: https://www.youtube.com/watch?v=Htt8AKeF1Kw, you will encounter the ...

Organizing HTML elements based on their class names, especially when an element has multiple classes assigned

Hey there, I've been working on an artist page that showcases multiple artists, each with a portfolio image and some detailed information. My goal is to have buttons at the top of the page that, upon clicking, will sort the artists displayed. To achi ...

Execute javascript function upon user scrolling to a designated section in the webpage

Is there a method to trigger a unique function every time a user scrolls to a different div or section of the page? ...

Press the [Submit] button to conceal DIV Container 1, reveal DIV Container 2, and populate DIVs discovered in a .PHP file within DIV Container 2

Trying to achieve the following steps: 1 - Press Submit Button 2 - Conceal DIV Container 1 3 - Reveal DIV Container 2 4 - Load and display all DIVs from "PricingDisclaimer.php" into Div Container 2 DIV Code snippet: <div id="MainContainer"> &l ...

Switching the focus of detection from a child to a parent

I am currently working on enhancing the functionality of my UI to display selections dynamically as they are selected or de-selected. import { Wizard } from './report-common'; import { Router } from '@angular/router'; import { DataServ ...

Dynamic cell editing feature in PrimeNG table

Looking to implement the PrimeNG Table. https://i.stack.imgur.com/bQycr.png Check out the live demo on StackBlitz. The table has three editable columns. The "Property Name" column always displays a text box in edit mode, while the "Property Value Type" ...

Tips for mocking constructors in AngularJS, specifically the Date() constructor

Trying to verify a function which receives millisSinceEpoch and gives back the time if it is today's date, otherwise it gives the date. getLocaleAbbreviatedDatetimeString: function(millisSinceEpoch) { var date = new Date(millisSinceEpoch); if (d ...

Can a file be imported into Node.js without the need for packaging?

Is there a way to have an entire file evaluated in node? For example, let's say I want to evaluate the angular.js source file. An example of what the code could look like is as follows: jsdom = require("jsdom").jsdom; document = jsdom("<html>& ...

To link circles vertically with a line and fill them with color when clicked, follow these steps:

I am looking to create a design similar to the image below using unordered list items. When a user clicks on a list item, I want the circle to fill with color. I have structured it by creating a div with nested list items and span elements. If a user click ...

Updating a URL in an HTML form with JavaScript

Currently, I am faced with the task of manipulating a variable's value in a JS file within a function that is responsible for dynamically updating values in an HTML table without necessitating a full website reload. The function code snippet appears b ...

Troubleshooting Asynchronous Code in JavaScript

I was experimenting with creating a brute force poll voting script. $('#vote').click(function(e) { var votes = 0; var attempts = 0; var failures = 0; for(var i = 0; i < 500; i++){ ...

What is the best way to pass a mask without using a plug-in when dealing with an input value in Vue.js?

As someone who has previously implemented the function using pure JavaScript, I am now faced with the challenge of incorporating it into vue.js and determining which lifecycle hooks are best suited for this task. This issue arises as I am a beginner prepar ...

Unable to open modal using a button in PHP

<?php $result = mysqli_query($con, $sql); while ($row = mysqli_fetch_array($result)) { echo '<tr><td>'; echo '<h5 style="margin-left:6px; color:black;">' . $row['id'] . '</h5> ...

Display error page when unable to load ng-view template

Is there a way to display a standard error page or template if a certain template cannot be loaded using ngRoute in Angular? I've come across suggestions that subscribing to the $routeChangeError event might help, but I'm not sure what steps to ...