I can't seem to get the dropdown list to appear. What could be the issue?

I'm currently trying to create a pure CSS dropdown menu on hover by following this tutorial. However, despite multiple attempts, I'm still stuck and in need of some clear explanations for my issue.

            <div class="navbar">
                <ul>
                    <li>
                    <div><a href="3d.html">3D Printing</a></div>
                        <ul>
                            <li>
                            <div><a href="#">blah</a></div>
                            </li><li>
                            <div><a href="#">blah</a></div>
                            </li><li>
                            <div><a href="#">blah</a></div>
                            </li>
                        </ul>
                    <li>
                    <div><a href="#"></a></div>
                    </li><li>
                    <a href="#"></a>
                    </li>
                </ul>
            </div>

So far, the HTML code seems fine to me.

    .navbar ul {
    position: relative;
    display: inline-block;
    font-family: lemon;
    list-style: none;
    padding: 15px 0px;
    font-size: 210%;
    margin-left: 3%;
    }
    
    .navbar ul:after {
    content: "";
    clear: both;
    display: block;
    }
    
    .navbar ul li {
    display: block;
    }
    
    .navbar ul ul {
    display: none;
    font-size: 100%;
    padding: 18px 5px;
    }
    
    navbar ul li:hover ul  {
    display: block;
    }
    
    .navbar ul ul li {
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    }
    
    .navbar ul ul li:hover {
    background: rgba(0,0,0,0.4)
    }
    
    .navbar ul li a {
    display: block;
    text-decoration: none;
    color: white;
    opacity: 0.8;
    }
    
    .navbar ul li a:hover {
    opacity: 1;
    }

The problem lies somewhere in this part of the code, but I can't seem to pinpoint it. Any assistance would be greatly appreciated!

Thank you in advance and warm regards.

Raymond The Hammer

Answer №1

Here is a suggestion for you to try:

<div class="navbar">
            <ul>
                <li>
               <a href="3d.html">3D Printing</a>
                    <ul>

                        <li><a href="#">blah</a></li>

                        <li><a href="#">blah</a></li>

                        <li><a href="#">blah</a></li>

                    </ul>
                    </li>

            </ul>
        </div>

Custom CSS styling:

   .navbar ul {
    position: relative;
    display: inline-block;
    font-family: lemon;
    list-style: none;
    padding: 15px 0px;
    font-size: 210%;
    margin-left: 3%;
    }

    .navbar ul:after {
    content: "";
    clear: both;
    display: block;
    }

    .navbar ul li {
    display: block;
    }

    .navbar ul ul {
    display: none;
    font-size: 100%;
    padding: 18px 5px;
    }

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

    .navbar ul ul li {
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .navbar ul ul li:hover {
    background: rgba(0,0,0,0.4)
    }

    .navbar ul li a {
    display: block;
    text-decoration: none;
    color: black;
    opacity: 0.8;
    }

    .navbar ul li a:hover {
    opacity: 1;
    }

Answer №2

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

Remember to include a dot before the navbar class

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

Check out this jsFiddle example

Note that it is not recommended to use div within ul li tags!

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 conceal just the scrollbar thumb in a Bootstrap modal?

When opening a modal in Bootstrap according to the documentation, it only hides the scrollbar thumb, like shown in the examples below: However, my modal hides the entire scrollbar. How can I modify it to hide only the scrollbar thumb? body { height: ...

Is there an issue with this website link?

What is causing the Xul app to display the error message: XML Parsing Error: not well-formed when encountering this code snippet: <browser class="AppBar" type="content" src="test.html?img1=img1.jpg&img2=img2.jpg" flex="4"/> specifically ...

The output from the Python and SQLite combination is accurate, however the HTML rendering is not displaying the data correctly

Retrieving data from a database using different methods can yield varied results. When the method is set to 'get', it returns all information, but when it's 'post', it only returns the searched item. Although the post method return ...

The vertical dimension of an element does not increase

Currently, I am working on a webpage with a header, page content, and footer sections. The issue I'm facing is that I set the page's height to height :auto;, but it's not functioning as expected. I actually need the page to automatically ex ...

Center a single div vertically within a parent div by utilizing a fluid layout

Attempting to align text elements within a responsive layout presents challenges due to the fluid nature of <div> sizes. I recently discovered a fantastic method for horizontally and vertically centering a child <div> inside its parent <div ...

Create a personalized preview image using specified parameters

Whenever I share a link to a specific location on Google Maps, the preview image of that location automatically appears, as shown below: https://i.stack.imgur.com/waBnb.png I have some knowledge about adding a preview image using the <meta> tag in ...

jQuery automatic slider for seamless transitions

I am in need of assistance with the coding for a website I'm currently constructing at www.diveintodesign.co.uk/ChrisMcCrone/index.html The coding being used is sourced from http://jquery.malsup.com/cycle/ The central large image functions as a slid ...

When implementing auto-generated IDs in HTML forms, rely on randomly generated values for increased uniqueness

When developing a form with multiple complex controls built as Backbone views, one wants to ensure that the labels are correctly linked to the input elements. This is typically done using the "for" attribute. However, in cases where the same control needs ...

Analyze HTML while maintaining the integrity of the initial content

I am facing a challenge with my HTML files. I need to replace certain elements while leaving the rest of the content untouched. Specifically, I am looking to run this jQuery expression (or something similar to it): $('.header .title').text(&apos ...

Is there a way to customize the timepicker pop-up so that it extends the entire width of the parent form control

<FormControl fullWidth> <LocalizationProvider dateAdapter={AdapterDayjs}> <TimePicker views={["hours", "minutes", "seconds"]} label={t("StrategyManager.Select_Time")} value={timer} ...

The inability of Chrome and Firefox browsers to open Windows folders directly from a hyperlink is a common

My link is directing to a Windows folder using its directory path. Surprisingly, it works perfectly fine in Internet Explorer but fails to work in Chrome and Firefox. How can I resolve this issue? The structure of my link looks like this: <a href="&bs ...

Leveraging LESS variables within media queries

After inputting the less code below into : @item-width: 120px; @num-cols: 3; @margins: 2 * 20px; @layout-max-width: @num-cols * @item-width + @margins; @media (min-width: @layout-max-width) { .list { width: @layout-max-width; } } The resul ...

I am looking to place two HTML buttons next to each other on the same line

I am trying to display two HTML buttons next to each other on the same line, with the "Submit Request(s)" button appearing first. The issue I am facing is that the top of the second button aligns with the bottom of the first one. The second button is cor ...

What is the best approach to retain a user's selection for dark mode?

I have created a small website to showcase my work, but I'm struggling to figure out how to make the website remember a user's choice of dark mode. After searching on Stack Overflow, I came across suggestions like using cookies or localStorage. ...

What is the best way to split <hr> tags into different sections?

I'm striving to create a design similar to this - https://i.sstatic.net/hcaST.png Initially, I attempted to use a hr tag and modify it for my purposes. However, my efforts have not yielded the desired outcome. Any assistance in understanding this co ...

Is there a way to delay rendering the html until all the content has been fully downloaded?

Whenever I visit my webpage, I notice that the content starts loading without the animation applied to it. It seems like the CSS hasn't finished downloading yet. To solve this issue, I added a preloading bar overlay to signal that the content is still ...

What is the best way to style radio boxes in HTML to resemble checkboxes and display X's when selected?

I'm looking to create a form with radio boxes that resemble checkboxes and display a glyphicon x when selected. I've experimented with various solutions such as: input[type="radio"] { -webkit-appearance: checkbox; /* Chrome, ...

Flashing Effect of Angular Ui-Bootstrap Collapse During Page Initialization

Below is the code snippet I've implemented to use the ui-bootstrap collapse directive in my Angular application. HTML: <div ng-controller="frequencyCtrl" style="margin-top:10px"> <button class="btn btn-default" ng-click="isCollapsed = ...

elements with a display of inline-block and a fixed body width

My inline-block elements are setting the width of the page, but the header and footer tags are not taking up the full width. Why is this happening and how can I make them span the entire page width? Check out the example here Here's the HTML code: ...

What methods can I implement to prevent my boxes from becoming stretched out?

How can I prevent this box from stretching too much? Here is the code snippet along with the output: CSS: .social { padding-left: 1000px; border: 5px inset black; margin: 4px; width: 100px; } HTML: <div class="social"> <p& ...