When an element within a dropdown is hovered over, a dropdown menu is triggered

As a newcomer to Web Development, I am facing a fundamental issue with my bootstrap navigation bar. The navigation bar contains multiple dropdown buttons that activate on hover. One of the buttons within a dropdown needs another dropdown to appear when hovering over 'Perioadele'. My lack of familiarity with HTML is making it challenging for me to implement this feature.

.dropbtn {
  background-color: #337ab7;
  color: black;
  padding: 16px;
  font-size: 16px;
  border: none;
  margin-top: 3px;
  margin-left: 20px;
  border-radius: 5px;
  font-family: Bitter;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  background-color: #f1f1f1;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
  border-radius: 5px;
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -ms-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
  height: 150px;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown-content a:hover {
  background-color: #ddd;
  border-radius: 5px;
}

.dropdown:hover .dropdown-content {
  opacity: 1;
  height: 240px;
  pointer-events: all;
}

.dropdown:hover .dropbtn {
  background-color: lightyellow;
}
<nav class="navbar navbar-dark bg-primary" id="navbar">
  <div class="container-fluid">
    <div class="dropdown" style="margin-left: 15px;">
      <button class="dropbtn">ROREG</button>
      <div class="dropdown-content" style="margin-left: 20px;">
        <a href="#">Istoric</a>
        <a href="#">Valoare propusa</a>
        <a href="#">Conducere</a>
        <a href="#">Responsabilitate sociala</a>
        <a href="#">Cariera</a>
      </div>
    </div>
    <div class="dropdown" style="margin-left: 5%;">
      <button class="dropbtn">FONDURI EUROPENE</button>
      <div class="dropdown-content" style="height: 132px; margin-left: 20px;">
        <a href="#">Catalog</a>
        <a href="#">Perioadele</a>
        <a href="#">Regulamente europene</a>
      </div>
    </div>
</nav>

Answer №1

I have successfully created a solution that meets your requirements.

Upon hovering over <a>Perioadele</a>, an additional menu will appear.

Feel free to test it out!

.dropbtn {
  background-color: #337ab7;
  color: black;
  padding: 16px;
  font-size: 16px;
  border: none;
  margin-top: 3px;
  margin-left: 20px;
  border-radius: 5px;
  font-family: Bitter;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  background-color: #f1f1f1;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
  border-radius: 5px;
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -ms-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
  height: 150px;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown-content a:hover {
  background-color: #ddd;
  border-radius: 5px;
}

.dropdown:hover .dropdown-content {
  opacity: 1;
  height: 240px;
  pointer-events: all;
}

.perioadele-content {
    display: none;
}

.perioadele-content:hover {
     display: block;
}

.pd:hover + .perioadele-content {
    display: block;
}


.pd:hover::after  + .perioadele-content {
  display: block;
}

.dropdown:hover .dropbtn {
  background-color: lightyellow;
}
<nav class="navbar navbar-dark bg-primary" id="navbar">
  <div class="container-fluid">
    <div class="dropdown" style="margin-left: 15px;">
      <button class="dropbtn">ROREG</button>
      <div class="dropdown-content" style="margin-left: 20px;">
        <a href="#">Istoric</a>
        <a href="#">Valoare propusa</a>
        <a href="#">Conducere</a>
        <a href="#">Responsabilitate sociala</a>
        <a href="#">Cariera</a>
      </div>
    </div>
    <div class="dropdown" style="margin-left: 5%;">
      <button class="dropbtn">FONDURI EUROPENE</button>
      <div class="dropdown-content" style="height: 132px; margin-left: 20px;">
        <a href="#">Catalog</a>
        <a href="#" class="pd" >Perioadele</a>
           <div class="perioadele-content dropdown-content" style="height: 132px; margin-left: 120px;">
            <a href="#">Perioadele A</a>
            <a href="#">Perioadele B</a>
            <a href="#">Perioadele C</a>
          </div>
        <a href="#">Regulamente europene</a>
      </div>
     
    </div>
</nav>

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 to use Python and JavaScript to make a WebElement visible in Selenium

I am currently facing an issue with uploading a PNG file using Selenium. The input element necessary for the upload process is visible to the user but not to Selenium. Following the suggestions in the Selenium FAQ, I tried using JavaScriptExecutor as shown ...

Vue.js: Issue with applying class binding while iterating over an object

I've been working with an object data that looks like this: object = { "2020092020-08-01":{ "value":"123", "id_number":"202009" }, "2020092020-09-01":{ "value& ...

Is it possible to automatically close navigation dropdowns when the screen size changes?

I am using a bootstrap 4 navbar with dropdowns that open with CSS animation/fade-in on desktop, and a separate toggle button for mobile. Everything works fine, but when I open the dropdowns on mobile and then resize the window screen, they remain open whic ...

How can I style the inner HTML text of an element without altering the style of its subelements? (CSS Selector)

I created an html structure that looks like this: <p> This is some test inside the p tag <div class="some-class"> <div class="sub-div-class"> <i title="title test" data-toggle="tooltip" class="some-icon-class" data-ori ...

Enabling draggable behavior for div elements on Mozilla Firefox

I've attempted the code mentioned in this forum but unfortunately, it's not working for me. I am currently using Firefox 15 and it seems to work fine in Chrome. Below is my code : <!DOCTYPE html> <head> <title>A Simple Dragg ...

Modify the text tone within a specific cell

Welcome to my unique webpage where I have implemented a special feature. The text highlighted in red represents the unique identifier for each individual cell. Interestingly, below there is an input field containing the code "0099CC", which corresponds to ...

JS animation triumphant

I have developed an app that utilizes a checkbox to control the appearance of an overlay on a screen. To ensure smooth transitions, I have incorporated animations into the process. #overlay{ position:absolute; height: 100vh; width: 100vw; ...

What is the best way to retrieve child component elements from the parent for testing in Angular 2?

Currently, I am facing a challenge where I need to retrieve an element of a child component from a parent component in order to conduct testing with Karma-Jasmine. In my setup, the parent component contains a contact form which includes a username and pass ...

Auto-fit HTML Webpage Resizer Simplified

Just finished my very first jQuery project, a simple full-width slider. I've been focusing on HTML & CSS and currently working with C#. The problem is that I don't want the page to be scrollable; I want it to autofit to the webpage. Imagine ope ...

Continue duplicating image to stretch header across entire screen

Looking to create a seamless connection between a Header image (2300x328px) and another image (456x328px) so that the header fills the entire width available without overlapping due to a pattern. I need the second image to extend the header to th ...

Position the Bootstrap Modal at the start of the designated DIV

When using a Bootstrap Modal to display larger versions of thumbnails in a photo gallery, there can be some challenges. The default behavior of Bootstrap is to position the modal at the top of the viewport, which may work fine in most cases. However, if th ...

Tips for creating distinct hover descriptions for each element in an array

My dilemma may not be fully captured by the title I've chosen, but essentially, I am working with a list of names and I want each one to display a unique description when hovered over with a mouse. On the surface, this seems like a simple task, right ...

The 502 Bad Gateway error strikes again on Google Drive

I have a website with numerous photos stored on Google Drive. The image tags in my code look like this: <img src="https://googledrive.com/host/<foldId>/A14.jpg"> Unfortunately, many of the photos are not loading and instead showing a 502 Bad ...

A guide on integrating Javascript and CSS files in Express.js

I'm currently running a simple node server from a page.js file as part of a system setup test. Here's the code snippet: var express = require('express'); var app = express(); app.get('/', function(req, res) { res.sendFil ...

Prevented: Techniques for providing extra cushioning for a button, but with the condition that it contains an external icon

How can I apply padding to a button only if it contains an external icon? If the button has an external icon, I want to give it padding-right: 30px (example). However, if there is no external icon present, then the button should not have the 30px padding. ...

What is the best way to eliminate unwanted white space at the top of the page?

I'm new to web development and I'm exploring the concept of white space at the top of a webpage. Here is a snippet of my code: HTML: <div> <p>lorem ipsum</P> </div> CSS: div { background-color: black; } I attem ...

It appears that the anchors and fragment identifiers are not functioning as expected

On my page somepage.html, I have the following markup: <div class='someclass' id='hashtag1'> <h1>somecontent</h1> </div> <div class='someclass' id='hashtag2'> <h1>somecontent& ...

What is the best way to narrow down the content cards displayed on the page?

I have recently developed a blog post featuring three distinct categories: digital marketing, tips and advice, and cryptocurrency. My goal is to implement a filtering system for these categories. For instance, I would like users to be able to click on a b ...

Loading background images in CSS before Nivo slider starts causing a problem

I've been struggling with preloading the background image of my wrapper before the nivo-slider slideshow loads. Despite it being just a fraction of a second delay, my client is quite particular about it -_- After attempting various jQuery and CSS tec ...

Creating a larger spinning div using CSS3 animation

I am looking to add a fun hover effect to my div where it spins and zooms in at the same time. Here is what I have so far: [html] div class="myMsg">> <p id="welly" style="color: #009">Welcome to Y3!<br><br><br>T ...