How come my div can alter its own attributes on hover, but its sibling cannot?

As I delve into the realm of web development, my initial project involves creating a portfolio site. However, I am facing difficulties with the dropdown section in one of the menus. I incorporated a :hover pseudo-class to the dropdownhover div to signal when to display the dropdown menu. Unfortunately, the dropdownnav class does not seem to change on line 67 as expected. I attempted altering the pseudo-class to only affect itself, which worked fine. However, when trying to modify a sibling class, it failed. Could this be due to a mistake with my combinators?

@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital@1&display=swap');

* {
    margin: 0;
    z-index: 0;
}

body {
    background-color: #EF2F88;
}

.navbar {
    background-color: #8843F2;
    margin: 0
}

.navlist {
    margin-right: 0;
    margin-left: 40%;
    height: 7rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    list-style: none;
}

.navlist li {
  height: 100%;
  text-align: center;
  flex: 1;
  position: relative;
}

.navlist li a {
    text-decoration: none;
    color: white;
    font-family: Source Code Pro;
    font-size: 2.5rem;
    top: 2rem;
    position: relative;
}

.dropdownnav {
    background-color: #8843F2;
    margin-top: 3rem;
    height: 8rem;
    opacity: 0;
}

.dropdownlist {
    justify-content: space-between;
    display: flex;
    gap: 1rem;
    flex-direction: column;
    list-style: none;
}

.dropdownlist li {
    text-align: left;
}

.dropdownlist li a {
    font-size: 1.5rem;
}

.dropdownhover:hover + .dropdownnav {
    opacity: 1;
}

.dropdownhover {
    position: absolute;
    top: 0;
    height: 15rem;
    width: 100%;
}
<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="UTF-8">    
        <link rel="stylesheet" href="styles.css"></link>
        <title>Portfolio</title>
    </head>
    
    <body>
            <!--NAV BAR SECTION-->
        <nav class="navbar">
            <ul class="navlist">
                <li id="about">
                    <a href="index.html">About Me</a> 
                </li">
                <li id="projects">
                    <a href="index.html">Projects</a> 

                    <nav class="dropdownnav">
                        <ul class="dropdownlist">
                            <li class="mania">
                                <a href="">Clicking Mania</a>
                            </li>
                            <li class="bloopville">
                                <a href="">Bloopville</a>
                            </li>
                        </ul>
                    </nav>

                    <div class="dropdownhover"></div>
                </li">
                <li id="skills">
                    <a href="index.html">Skills</a> 
                </li">
                <li id="contact">
                    <a href="index.html">Contact</a> 
                </li">
            </ul>
        </nav>
    </body>
</html>

Answer №1

.dropdownhover:hover + .dropdownnav:hover {
    visibility: visible;
}

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

Currently at the beginning stages of mastering CSS and encountering difficulties with the display property

I am facing an issue with my code .name-bar, .email-bar { border-color: gray; border-style: solid; display: inline-block; } .email-bar { margin-top: 5px; } .div-one, .div-two { border-color: gray; border-style: solid; width: 200px; h ...

After utilizing the function, the forward and back arrows are no longer visible

After setting up my slideshow, I encountered an issue where clicking the next or previous buttons caused them to shrink down and turn into small grey boxes. Has anyone experienced this before? This relates to PHP/HTML if ($_SERVER['REQUEST_METHOD&ap ...

Using CKEditor in an AngularJS web application: Tips and tricks

I'm having trouble integrating the ckeditor into an HTML page that's built with angularjs. Despite trying out numerous examples, such as the ng-ckeditor and ckeditor directives, I haven't found a solution that works for me. What I need is ...

Having trouble with the link attribute not functioning properly for a radio button in Chrome?

<a> hyperlink for radio button is not functioning correctly in Chrome. Here is the code segment in question: <td width='7%' bgcolor='#E8E8E8'> <a href='issue.php?admin=Yes&&user=$user'> <inp ...

Struggling with Duplicated Images

Currently working on a website using only HTML and CSS. I am still learning the ropes in this area. My goal is to create a layout with a header, body, and footer that repeat to fill up the entire page, similar to envato.com. Here is a snippet of the code I ...

Creating an Unordered List in GWT that Includes List Items

I've hit a roadblock while trying to create a css-driven menu in GWT. The menu should be rendered exactly like this: <div class="topbar"> <div class="container fixed"> <h3> <a href="" class="logo">test& ...

Tips for styling your Angular Material Card on mobile devices

Currently, I am very happy with my desktop layout which looks like this: https://i.stack.imgur.com/tG0pw.png However, when it comes to the mobile version of my site, here is what I have so far: https://i.stack.imgur.com/KD1hh.jpg While I do like the ho ...

What is the best way to display a variable (string/int) from a PHP file onto an HTML file?

I've searched online multiple times for a solution, but most of the results I found only show how to echo HTML code from a PHP file by changing the file extension to .php. However, my goal is to echo a variable from a PHP file and display it in an HTM ...

Two-column list using XSLT

I am seeking assistance with xsl transformation. The xml generated by SharePoint Server control is as follows: <rows> <row>A</row> <row>B</row> <row>C</row> <row>D</row> <row>E ...

Can we set a restriction on the maximum number of children a particular div can contain?

I'm trying to find a way to restrict the number of children in a div. The concept is that there is a selected commands div where you can drag and drop available commands (essentially buttons) from another div called available commands. However, I wan ...

jQuery Load - Oops! There seems to be a syntax error: Unexpected token <

Error: Uncaught SyntaxError: Unexpected token < I encountered the error message mentioned above while trying to execute a jQuery load function: $('#footer').load(UrlOfFooterContent); The variable UrlOfFooterContent holds the URL of an MVC c ...

The issue of undefined database columns arises when attempting to transmit data from an HTML form to a MySQL database via Express

My primary objective is to develop a RestAPI using Node.js and test it in a small HTML application. With the guidance of my instructor, I successfully created the RestAPI based on an example and customized it to work with my own MySQL database. Testing ea ...

How can I manage the pageWidth property in the layout of my xPage Bootstrap app?

Check out these two examples - one with app layout and the other with just a navbar, both with fixed pageWidth settings. <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex"> <xe:applicationLayout id="a ...

HTML needs to be wrapped around every set of three items using C# ForEach loop

Currently, I am faced with the task of constructing an HTML code structure within C# code behind. Specifically, I need to insert an HTML element that spans 3 columns in a row of 12 columns (utilizing Zurb Foundation). To achieve this, I am iterating throu ...

How can I use Selenium in combination with Python to retrieve the visible text of a selected radio button or checkbox on a webpage?

I am currently working on processing a form where I need to extract the text values of all checked radio buttons. Each line item will have one radio button checked. Here is an example of the HTML structure for a checked radio button: <div style="white ...

The width of sibling divs in IE7 does not match their sibling's width

Currently facing a challenge with resolving an IE7 problem. My goal is to ensure that my sibling div has the same width as its counterparts. The initial sibling serves as the header, whereas the subsequent siblings have specific dimensions. Any advice woul ...

What is the process for incorporating the !important declaration into a CSS-in-JS (JSS) class attribute?

I'm currently exploring the use of CSS-in-JS classes from this specific response in conjunction with a Material UI component within my React project. In order to override the CSS set by Bootstrap, I've decided to utilize the !important modifier. ...

Ionic 4 Tabs with Smooth Scrolling

I recently started using Ionic 4 and I'm trying to create scrollable tabs in Ionic 4. However, when I include multiple tabs as shown in the code below, they become compressed and appear within the same viewing space. <ion-tab-bar slot="top"> ...

Do GPU-intensive animations get impacted by the CPU's load?

I have set up a special compositing layer for a div with the following unique styles: div { position: absolute; height: 50px; width: 50px; background: #900; top: 100px; left: 200px; will-change: transform; transform: translateZ(0); } Afte ...

Flexbox Resizing Notification(?)

Recently, I've been utilizing flexbox in my layout design and it has been a game-changer. However, I am facing an issue that might be linked to my heavy use of AngularJS, particularly the ng-include feature. The specific problem arises when I incorpo ...