What could be causing my submenu to not display the specified hover effect?

Help needed troubleshooting dropdown menu issue in HTML and CSS. Using :hover to switch from display:none; to display:flex;. Want submenu to appear when hovering over "Unsere Produkte". Grateful for any assistance. Thank you.

/* Desktop Navigation Bar fixed*/
.hidden{
    display:none;
    flex-direction: column;
    position: absolute;
    z-index: -5;
    background-color: #FFFEF9;
    padding-left:2%;
    padding-right:2%;
    transition: all .375s;
}
.hidden a{
    margin-top: 5%;
    margin-bottom: 5%;
    background-color: #FFFEF9;
}
.hidden a:hover{
    color: #BF9D1D;
}
#produkt:hover > .hidden {
    display:flex;
    z-index: 888;
    flex-direction: column;
    position: absolute;
    z-index: -5;
    background-color: #FFFEF9;
    padding-left:2%;
    padding-right:2%;
    transition: all .375s;
}
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="styles.css">
    
</head>
<body>
<div class="fixed-nav">
    <div class="header">
        <div class="col-1 head-1"></div>
        <div class="col-3"></div>
        <div class="col-1 sans-serif-caption xy">
            <div class="header-box1 col-4 sans-serif-caption">
                <li class="space"><a href="#UeberUns">Über Uns</a></li>
                <li class="space hidden-1">
                    <a id="produkt">Unsere Produkte</a>
                    <ul class="hidden">
                        <a href="#">Unterfußdüngung mit KS NP MIX</a>
                        <a href="#">HARMI-SOIL 8.0/15 </a>
                        <a href="#">Agrimax Konzentrat</a>
                    </ul>
                </li>
                
            </div>
            <div class="header-box2 col-4">
                <li>
                <image src="media/logo_2.svg" alt="logo"/>
                </li>
            </div>    
            <div class="header-box1 sans-serif-caption col-4">
                <li class="sans-serif-caption space"><a href="#Kontakt">Kontakt</a></li>
                <div class="search sans-serif-caption">
                    <input type="text" placeholder="Suche">
                    <image src="media/search-24px.svg" alt="search-icon" />
                </div>
                <div class="language-button row sans-serif-caption">
                    <image src="media/language-24px.svg" alt="language-icon" width="14px"                            height="14px"/>
                    <a>de</a>
                </div>
            </div>    
        </div>
    </div>
</div>
</body>
</html>

Answer №1

When using the ">" selector, it targets a direct CHILD element.
In your html code, <a id="produkt"> and

<ul class="hidden">
are siblings.
To select sibling elements instead, use the "~" symbol.

Here is an example:

#produkt:hover ~ .hidden {
    display:flex;
    z-index: 888;
    flex-direction: column;
    position: absolute;
    z-index: -5;
    background-color: #FFFEF9;
    padding-left:2%;
    padding-right:2%;
    transition: all .375s;
}

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

Sending values from multiple input fields created in PHP using AJAX can be done by following these steps

https://i.sstatic.net/GKcRc.png Within this snippet, there is a portion of a form that consists of 4 different fields/divs like the one shown. I am struggling to figure out how to send the values of these input fields to PHP using AJAX. I apologize if ...

The HTML code is not being styled by Bootstrap

<div class="form-inline"> <div class="form-group "> <label for="txtTitle" class="control-label"> <p class="text-info">Page Title</p> </label> <asp:textbox id="txtTitle" tabindex ...

The error message "QuerySet object does not have a save attribute."

I'm currently working on this page to update filled-in details in a MySql database named TL when the update button is clicked. https://i.sstatic.net/RmR2z.png However, upon clicking update, I encounter the following error: AttributeError at /add/ &a ...

In configuring the print settings, I specified margins to ensure proper formatting. However, I noticed that the margin adjustment only applies to the first page. I need

I have a method that retrieves margin top value from the backend. It works perfectly on the first page of print, but on the second page, the margin top space is missing. initializePrintingSettings() { this.printService.fetchPrintSettings().subscribe(respon ...

What sets apart compressing test.min.css from compressing test.css?

Recently, I have transitioned to a new job role with a different employer. In my previous workplace, we utilized LESS and compiled it into a .css file before compressing it further into a .min.css file. However, in my current position, we also work with L ...

Issue with custom leaflet divIcon not maintaining fixed marker position during zoom levels

After creating a custom marker for leaflet maps, I noticed that it shifts position drastically when zooming in and out of the map. Despite trying to adjust anchor points and positions, the issue persists. I have provided the code below in hopes that someon ...

How come the transition does not take effect when removing and adding the class to the same element with the removeClass() and addClass() methods?

Two images are present, with the first one having the class "opacityOne". When a button is clicked, based on the variable index, I want the current image to fade in while the other fades out. It works well when I remove the "opacityOne" class from one ima ...

Navigation Menu Spanning Across Full Width of All Screens

Hello! I am currently working on designing a responsive menu using HTML5 and CSS. My approach involves creating a navigation menu for desktop computers and implementing a checkbox with a label to reveal the responsive menu when needed. Here is the code s ...

Having trouble customizing the appearance of wtform attributes

Hello Everyone, Here is the content of the .py file: from flask import Flask, render_template, flash, session, redirect, url_for from flask_wtf import FlaskForm from wtforms import StringField,SubmitField from wtforms.validators import Da ...

What is the best way to alert a user before they navigate away from a page with content in a textarea?

I am attempting to recreate the functionality seen on textareas in Stack Overflow. UPDATE: Following the advice provided here, I have implemented something similar to the following: window.onbeforeunload = function() { var myTextArea = document.getE ...

Double-column design for viewing on both computers and mobile devices

Check out my fiddle: https://jsfiddle.net/b6q7pmkg/ I'm attempting to create a layout with two-column cards that will maintain two-column structure across both mobile and desktop viewports. Here's what I envision: On desktop: https://i.sstatic.ne ...

Choosing a value from a dropdown automatically based on the selection of a specific value from another dropdown

Currently, I am working on a project that involves selecting a value from a dropdown menu based on the selection from another dropdown menu. var gender1 = document.querySelector("#gender1"); var gender2 = document.querySelector("#gender2"); gender1.add ...

Using getServerSideProps in Next.js is preventing the global css from loading

In my Next.js application, I have defined global styles in the file /styles/globals.css and imported them in _app.tsx. // import default style import "../styles/globals.css"; function MyApp({ Component, pageProps }) { return <Component {...pageProps ...

Ways to speed up the disappearance of error messages

There is a minor issue that I find quite annoying. The validation error message takes too long (approximately 3 seconds) to disappear after a valid input has been entered. Let me give you an example. https://i.sstatic.net/8UKrm.png Do you have any tips o ...

customizing the appearance of a plugin

Visit the live site here. I am attempting to customize the text displayed in black under the Upcoming Events section. Despite multiple attempts using different combinations such as .vevent-item odd event-1 .description .event-time .event-label, I have not ...

Learn how to reposition the mat-option easily

I have an angular app with an autocomplete field that I need to adjust the position of. I have consulted the official documentation under the method updatePosition, which states: "Updates the position of the autocomplete suggestion panel to ensure that it ...

Ways to evaluate the amount of traffic on a webpage?

Recently, I encountered an issue while creating a page to showcase blog posts. Each post had the typical social media share buttons like "Facebook like," "tweet this post," and "+1." Additionally, there were some extra JavaScript functions added for variou ...

Guide to switching classes with jquery

On my webpage, I have a star rating system that I want to toggle between "fa fa-star" and "fa fa-star checked" classes. I found some information on how to do this here: Javascript/Jquery to change class onclick? However, when I tried to implement it, it di ...

Resolved z-index problem in modal dialog box

My fixed modal has a z-index set to 100, but it seems to be positioned below an element with a z-index of 2 and a position set to relative. I'm not sure why this is happening. You can view the code in this fiddle. Any insights or assistance would be g ...

Setting up a checkbox to accept either a 0 or 1 value from a database

I am trying to integrate an HTML table where each table data cell contains a drop-down menu and a checkbox. These elements are connected to a database table named "checkbox" which contains values of 1s and 0s. I want to dynamically display the check box as ...