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

PHP mistakenly outputs content that is not enclosed within tags

After discovering StackOverflow, I couldn't resist sharing my PHP code conundrum with the incredible community here! So, in a WordPress template, I have this chunk of PHP: echo '<div class="thumbnail">'; echo the_post_thumbnail(); ec ...

Problem with Agile Carousel and thumbnail component

I have incorporated the Agile Carousel plugin into my website to create multiple slideshows. The first slideshow at the top is working fine, but I am experiencing an issue with the carousel in the "About" section at the bottom. While I have successfully se ...

How to position a static element using CSS

I'm trying to align an image in the center of the screen, but I've run into some trouble. Typically, this is easy by setting the width of a div and using margin: auto;. However, I also need the div to have the position: fixed; property, which see ...

How can we ensure that pointer events return the same coordinates as touch events when the viewport is zoomed in?

I attempted to utilize pointer events (such as pointerdown) instead of using a combination of touch events (e.g. touchstart) and mouse events (e.g. mousedown) to determine the input event coordinates. var bodyElement = document.body; bodyElement.addEvent ...

What is the best way to extract the innerHTML of every button and exhibit it in a text box?

How can I create a simpler JavaScript code for clicking buttons to input letters into a text box? Instead of creating getElementByID for each button, is it possible to use some kind of loop? <div id="alpha" > <br/> <div align="cente ...

Using React Refs to Trigger the video.play() Method - A Step-by-Step Guide

Is there a way to use a ref in order to trigger video.play()? Currently encountering an error: preview.bundle.js:261916 Uncaught TypeError: _this2.videoRef.play is not a function Take a look at my component: import React from 'react'; import s ...

Skip ahead button for fast forwarding html5 video

One of the features in my video player is a skip button that allows users to jump to the end of the video. Below is the HTML code for the video player: <video id="video1" style="height: 100%" class="video-js vjs-default-skin" controls muted autoplay=" ...

When using the HTML code <p></p>, the empty paragraph tag does not create a line break

We have a .NET application that saves messages in axml format. Our task is to convert these messages into html. After some research, I came across a 3rd party library called "HtmlFromXamlConverter" that does this job, but with one issue: when the axml cont ...

"Going beyond the ordinary: An exclusive look at the Outlook newsletter design

I'm struggling with adding text and a background image to a TD in a newsletter. While the background shows up, the text is not being displayed as expected. Below is the code snippet I've been using: {if !empty($aModules.mkNews)} ...

Learn how to utilize interpolation within an *ngIf statement in Angular 2 in order to access local template

Consider the following scenario; <div *ngFor="item of items; let i = index;"> <div *ngIf="variable{{i}}">show if variable{{i}} is true</div> </div> Suppose I have variables named "variable0", "variable1",... Is there a way to ac ...

Troubleshooting a jQuery Selector Issue with a Dynamic Form

I developed a jQuery function to search for all the necessary inputs in a specific section of a website. function check_property_vars() { jQuery(this).parents('.property_group').find('div[id^="property_group_"]:input[required]:visible&a ...

What causes the size of text to change when I zoom in my browser?

As I work on my website, I am facing a challenge with maintaining consistent text size as the page scales. For example: p { width: 10%; height: 10%; background-color: rgb(0,0,0); top: 50%; left: 50%; position: fixed; color: rgb(255,255,25 ...

Guide to building a personalized autocomplete feature in vue js

Presently, I am using the buefy autocomplete feature, but it is causing a few problems. In the DepartmentDetail.vue file <template slot-scope="props"> <div class="container is-fluid"> <b-loading :is-full-page=" ...

What could be causing my Angular.js application to malfunction on IE7?

I have developed an Angular.js application that is working well on most browsers, but I am now facing compatibility issues with IE 7 and above. I have tried different approaches such as adding id="ng-app", using xmlns:ng, manually bootstrapping angular wi ...

Ways to divide a foreach loop or for loop into sets of 10 records

Let's say I have 56 entries in my database. To display them, I am using a FOR LOOP. My goal is to add a div element after every set of 10 records. <?php $totalRecords = 56; for($i=0; $i<$totalRecords; $i++){ e ...

How to display logged-in user information on the homepage

Code for multiuser login $scope.users = [ {uname: 'fida', password: 'fida', age:26, department:"science"}, {uname: 'anu', password: 'anu', age:23,department:"maths"}, {uname: 'nida&apo ...

The JavaScript code is not running as expected!

i have this index.html file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" ...

Issues arise when the elements <html> and <body> fail to adhere to a 100

Lately, I've been struggling with various problems related to heights. I was able to resolve the height issues of certain elements using flex:auto and flex-shrink:0. However, I'm facing difficulties getting the HTML and Body tags to cooperate ( ...

Issue with inner span not inheriting max-width set on outer <td> element

Whenever I hover over a table cell, the Angular Bootstrap popover should appear next to the text. However, the 'span' element remains at its full width. <td style="max-width: 50px; text-align: left; white-space:nowrap; overflow:hidden; text- ...

What is the best jQuery library to add to my website?

I have included several jQuery scripts on my website for various functionalities such as sticky header, anchors, and animations. I am wondering if it is necessary to include all of them or if I can just include one or two? Here are the jQuery scripts I ha ...