`Selecting the ideal dropdown menu placement`

I've been working on creating a drop-down menu using CSS, and I've managed to hide the drop down menu successfully. However, I'm facing difficulty in making it reappear. I suspect that the issue lies with the :hover tag, which I have removed from the css as I haven't been able to get it to function properly. Can anyone assist me with the CSS? Help, please! I am desperate for a solution.

Here is the HTML Code:

<div id="navigation">
    <ul id="menu">
        <li class="menu"><a href="#home">Home</a></li>
        <li class="menu"><a href="#news">About Us</a></li>
        <ul class="sub_menu">
            <li>Our Mission Statement</li>
            <li>How Funds Are Spent</li>
            <ul class="sub_sub_menu">
                The Founders
                <li>A</li>
                <li>B</li>
                <li>C</li>
                <li>D</li>
                <li>E</li>
                <li>F</li>
            </ul>
        </ul>
        <li class="menu"><a href="#contact">What We Do</a></li>
        <ul class="sub_menu">
            <li>T-Shirt Designs</li>
            <li>Future Design Ideas</li>
            <ul class="sub_sub_menu">
                Fact Sheets
                <li>How Our Fact Sheets Work</li>
                <li>Fact Sheet 1</li>
            </ul>
        </ul>
        <li class="menu"><a href="#about">Media</a></li>
        <li class="menu"><a href="#contact">Contact Us</a></li>
    </ul>
</div>

The CSS code I am using is as follows:

ul {
    position: absolute;
    list-style-type: none;
    margin: 0;
    padding: 0;
    padding-top: 0px;
    padding-bottom: 0px;
}
li.menu {
    display: inline
}
a:link, a:visited {
    font-weight: bold;
    font-size: 14px;
    color: #FFFFFF;
    background-color: #B4B7BD;
    text-align: center;
    padding-top: 3px;
    padding-bottom: 3px;
    padding-right: 20px;
    padding-left: 20px;
    text-decoration: none;
    text-transform: uppercase;
}
a:hover, a:active {
    background-color: #B4B7BD
}
ul.sub_menu li {
    position: relative;
    display: none;
    width: 100%;
}
ul.sub_sub_menu {
    position: relative;
    display: none;
}
ul.sub_sub_menu li {
    position: relative;
    display: none;
    width: 100%;
    left: 100%;
}

Answer №1

HTML and CSS Troubleshooting

Let's address some issues in your code:

<ul class="sub_sub_menu">The Founders

Having text inside an unordered list tag is not allowed. Consider placing the text in a list item instead.

Additionally, ensure that your nested lists are structured correctly like this:

<li class="menu"><a href="#news">About Us</a>
    <ul class="sub_menu">
        <li>Our Mission Statement</li>
        <li>How Funds Are Spent</li>
    </ul>
</li>

For CSS modifications, consider using this code snippet for rollover effects:

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

Make sure to optimize your selectors by using class names directly rather than prefixing with element types:

.menu
.sub_menu
.sub_sub_menu

By following these suggestions, your HTML and CSS should function smoothly. Happy coding!

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

How can I use CSS to position one div on top of another div, without it moving when the page is scrolled down?

I have two images, one rectangle and one circular. The rectangle image needs to be positioned 10em lower due to a banner image at the top. Half of the circle should overlap with the rectangle while the other half remains outside. The center of the circle m ...

What is the proper way to structure keywords in Microdata for a CreativeWork?

As I delve into Microdata, I am exploring the utilization of Schema.org's keywords for CreativeWork. The schema indicates that it should be text, but I am unsure whether to place each keyword in a separate element with itemprop="keywords", or include ...

What could be causing the image to peek through the color overlay?

When I add a black overlay to images, I notice that the edges of the row of images slightly peek out from under the overlay. The size of the images seems to affect this issue differently. Check out the CodePen below to see it in action with Bootstrap 4 CSS ...

CSS3 animations and transitions offer dynamic and engaging effects for websites

Could CSS3 animations be utilized for scrolling a window? In jQuery, you would typically use something like: $(window).animate({scrollTop: '+=200'}, 300, function() { }); Therefore, my inquiry is whether it is feasible to achieve a similar effe ...

apply a border-radius to the top right corner only without affecting the other sides or background

https://i.sstatic.net/9YIiy.jpg I have been working on creating the top right triangle design shown in the image. However, I encountered an issue where applying border radius seems to affect all sides instead of just one as intended. Despite using border- ...

In JavaScript, the gallery feature with Lightbox effect creates a unique touch as only half of the screen fades to black in

Hello everyone, I'm a complete beginner when it comes to programming so please be gentle with me on my first question :) I'm trying to put together a simple website with a lightbox gallery, and you can check out what I have so far here. The prob ...

How can I use CSS to change the background color of a fixed navbar when scrolling?

Is it possible to use only CSS to alter the background color of a fixed navbar once the user has scrolled past a specific point vertically? I am curious if this can be accomplished in CSS by targeting the ID of another element, or possibly its height? Alt ...

Problems Arising from Center Aligning a Horizontal Navigation Menu

I have attempted various methods to shift the navigation bar as a whole, but I am facing a roadblock. The container for the navigation bar needs to adjust its size based on the size of the navigation bar. Since the number of links will change periodically, ...

What is the most effective method for tracking file upload progress using SSE?

I am currently working on creating a file upload progress feature that is compatible with older browsers using AJAX. In HTML5, there is the xhr.upload.progress event which works well for modern browsers, but I need an alternative for non-XHR2 browsers. I h ...

Retrieve the Vue.js JavaScript file from the designated static directory

This is my inaugural attempt at creating a web application, so I am venturing into Vue.js Javascript programming as a newcomer. I have chosen to work with the Beagle Bootstrap template. Within my Static folder, I have a file named app-charts-morris.js whi ...

The dropdown list is nowhere to be found in the page source when using Selenium

Currently, I am engaged in web scraping using Selenium. Successfully locating the input box and entering ID numbers is no issue. Yet, a roadblock presents itself - there is no submit button linked to the search bar. Once the numbers are inputted, the box a ...

Customizing the appearance of an HTML element using user-input text styling

On my webpage, there are two text areas and a division. One of the text areas is meant for users to input HTML code, while the other is for CSS code. Whenever a button is clicked, a JavaScript function will be triggered to display the combined HTML and CSS ...

I am looking to display text dynamically on a web page that is retrieved from a MySQL database and shown in a text box

Here is the code snippet I'm working with: // Set up event listener for when ".thoughts_box" input field loses focus $(".thoughts_box").blur(function(){ var box_id= $(this).attr("id").split("_")[$(this).attr("id").split("_").length-1]; // Cal ...

issues with functionality in purecss drop down menu

I have been struggling to create a vertical drop-down menu using the purecss library without success. purecss.io/menus/ This is what my CSS code looks like: <div class="pure-menu custom-restricted-width"> <ul class="pure-menu-list"> ...

Numerous websites with scroll-based navigation

I am currently building a unique website that includes scrolling in various directions without the use of a horizontal scrollbar. The design is similar to this image: https://i.stack.imgur.com/Ex2Bf.jpg. It is a one-page website where vertical scrolling ...

Incorporating a stationary navigation bar alongside a parallax scrolling layout

After spending the entire night trying to figure this out, I have had zero success so far. I decided to tackle this issue with javascript since my attempts with CSS have been completely fruitless. This is a demonstration of the parallax scrolling webpage. ...

Methods for incorporating rtl functionality into Angular Chosen

I am currently using Angular with Chosen (source) and I am attempting to implement right-to-left (RTL) support. Here is my demo, but despite referencing resources, I am encountering issues. The main problem arises when the body element has a dir="rtl" att ...

Experiencing blank areas when I try to minimize the screen while using Chrome

While using Chrome, my webpage looks perfect in normal mode. However, when I minimize the screen, white space appears at the bottom and some content gets hidden. The page is built using reactjs, html, and css. Interestingly, it works fine for IE in both no ...

Just beginning my journey with coding and came across this error message: "Encountered Uncaught TypeError: Cannot read property 'value' of null"

As a newcomer to the world of coding, I am excited about working on a side project that allows me to practice what I am learning in my courses. My project so far is a temperature calculator that incorporates basic HTML and JS concepts. My goal is to improv ...

Aligning a div element horizontally

I'm having trouble aligning the div element with the .slider class horizontally. The margin: 0 auto; property doesn't seem to be working. Additionally, I would like to know how to make the slider image responsive. /* CSS Document */ .header { ...