Hovering over the main navigation will reveal the sub navigation bar underneath

I am trying to implement a sub navigation bar using bootstrap that resembles the design in the image provided below. Specifically, I would like the 'Advertising' tab on the main navigation bar to reveal two sub pages titled 'How It Works' and 'Our Partners' when hovered over. I want these links to be displayed in a subnav bar located beneath the main nav bar. Despite attempting numerous online examples, I have been unsuccessful in getting this functionality to work. Can anyone provide guidance on how to achieve this?

https://i.sstatic.net/b6vV0.jpg

Answer №1

Give this a shot:

I implemented bootstrap V3.3.6

Here's an example: https://jsfiddle.net/pfss9b28/

HTML:

<div id="navbar">    
    <nav class="navbar navbar-default navbar-static-top" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
        </div>

        <div class="collapse navbar-collapse" id="navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li><a href="#">About</a></li>

                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Advertising <b class="caret"></b></a> 

                    <ul class="dropdown-menu">
                        <li><a href="#">How It Works</a></li>
                        <li><a href="#">Our Partners</a></li>

                    </ul>
                </li>
                <li><a href="#">Press</a></li>
                <li><a href="#">Contact</a></li>
                 <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Test other child <b class="caret"></b></a> 

                    <ul class="dropdown-menu">
                        <li><a href="#">child 1</a></li>
                        <li><a href="#">child 2</a></li>
                        <li><a href="#">child 3</a></li> 
                        <li><a href="#">child 4</a></li>
                        <li><a href="#">child 5</a></li>                            
                    </ul>
                </li>
           </ul>
        </div>
    </nav>
</div>

CSS:

.navbar-default{
  background:#333;
  color:#fff;
} 

.navbar-default .navbar-nav > li > a{
    color:#fff !important;
}
.navbar-default .navbar-nav li a:hover{text-decoration:underline}
.navbar-default .navbar-nav > li.dropdown > a{position:relative;}
.navbar-default .navbar-nav > li.dropdown:hover > a:after{
    background: #333;
    content: " ";
    display: block;
    height: 15px;
    left: 20px;
    position: absolute;
    top: 100%;
    margin-top:-10px;
    transform: rotate(45deg);
    width: 15px;
    z-index:10001;
}
.navbar-default .navbar-nav > .active > a,.navbar-default .navbar-nav > .active > a:hover,.navbar-default .navbar-nav > li > a:hover{background:#333;color:#fff;text-decoration:underline;}
.nav > li{
    position:inherit;
} 
.dropdown-menu{
    left: 0;
    min-width: 100% !important;
    position: absolute !important;
    right: 0;
    background:#E1E0DE;
    padding:13px 0px;
}

.dropdown-menu > li{
    display:inline-block;
}
.dropdown-menu > li > a:hover, .dropdown-menu > .active > a:hover {
  text-decoration: underline;
  background:#E1E0DE;
}  
ul.nav li:hover > ul.dropdown-menu {
    display: block;
}

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

Bizarre Incident Management

My latest project involves a simplistic website featuring arrow images (png) positioned on the left and right sides with fixed placement, allowing users to navigate to the next page. However, an issue arises where the cursor seems unable to select the an ...

The jQuery Bootstrap extension functions correctly on Firefox, but encounters compatibility issues on IE10

My code is based on jQuery 2.1 and bootstrap 3.2. It runs smoothly in Firefox, but encounters issues in IE10. I have added <meta http-equiv="X-UA-Compatible" content="IE=edge"> to the header to address compatibility mode concerns, yet the problem per ...

Angular 4.3 - Best Practices for Utilizing Enums in a Nested Component

Today, I encountered an issue trying to access the selected value from an enum in my contact.component file. This enum is a part of a form. Here is how I set up the enum: contact.component.ts (extract of relevant code only) import { Component, OnI ...

How to disable an anchor tag based on a condition using ng-class?

I have a displayed table that includes a column called count which has an <a> tag with a href to a page. I want to show a link for all rows where count > 0 and disable it when count=0. I attempted to use AngularJS - ng-disabled not working for An ...

Tips for altering the distance between dots on a line

.ccw--steps { margin: 10px auto; position: relative; max-width: 500px; } .ccw--step-dot { display: inline-block; width: 15px; border-radius: 50%; height: 15px; background: blue; border: 5px solid #e8e8e8; position: relative; top: -8p ...

Error: Popper is not found in the Bootstrap bundle even after importing it

Having some issues with bootstrap4. I have imported the bootstrap.bundle.js which includes popper.js. Despite this, I keep encountering the following error: Uncaught ReferenceError: Popper is not defined This is how I've included the scripts: < ...

Angular's ng-model is unable to access the value of an object array

When selecting the days, users should be able to input check-in and check-out time ranges dynamically. However, there seems to be an issue with retrieving the values and data format. The ng model is unable to capture the check-in and check-out values. The ...

Tips on causing a div to overflow instead of wrapping onto a new line

Are you looking to design a slider with 3 image containers all in the same row, where the third one overflows instead of wrapping to a new line? Here is an example: Desired Design: https://i.stack.imgur.com/dKyEg.png Current State: https://i.stack.imgu ...

Incorporate an XML buffer into the form data

Currently, I am facing an issue while attempting to upload an XML file using superagent (Protractor Testresults) within a NodeJS context. My approach involves using 'fs' to read the XML file using readFileSync, which results in a Buffer Object fo ...

The text inside a paragraph tag is causing other elements to shift when the window size is changed

With three divs displayed inline, each containing an image, heading, paragraph, and anchor tags, a design issue arises. The inconsistency in text lengths under the images causes visual discrepancies when resizing the window. For example, while the first tw ...

Tips for getting my scripts to function properly with my components in next.js?

I am facing an issue with my script while using React and Next.js in my pages/_app.js file. The code snippet is as follows: import axios from "axios"; import { $ } from "jquery"; import App from "next/app"; import Router from ...

Ways to identify an element within a webpage

I'm currently working on creating a chrome extension that can detect the presence of specific elements on a webpage. The goal is to have this extension automatically run every time a new page is opened and display a popup message if the element is fou ...

Tips for generating dynamic scope variables in AngularJS?

I would like to create a screen with select dropdowns and input fields that do not affect each other. Currently, if I select a company, it shows as selected in the next set, which should not happen. How can I implement this? 'use strict'; ang ...

Order of flexbox items when placed within separate divs?

Looking to rearrange the order of items using flexbox, but hitting a roadblock because one of the items I want to reorder is in a different div and not a direct child of the same parent as the other items. <div class="wrapper"> <div class="some ...

Customize button design with data from API request

I am currently working on a project to showcase the status of multiple servers within a cluster. To achieve this, I have established a status route in my web service that returns 'ok' if the server is functioning correctly and an error message if ...

When using jQuery to submit a form, the page is refreshed rather than actually submitting

I created a script to submit a form with a delay: $(document).ready(function () { $('#form-submit').on('click', function (event) { event.preventDefault(); // event.stopPropagation(); $('#big-dots-loade ...

Generate a text input field within a dropdown menu

Below is an example of my basic HTML code for a drop-down list: <span id="Div_List"> <label for="Gender">For:</label> <select name="Gender" id="Sex"> <option value="1">1000mtr</option> <option val ...

What is the process for creating a progress bar in PixiJS?

Can someone guide me on creating a progress bar similar to the one in PixiJS? Screenshot ...

Having an issue with retrieving value from a textfield in JavaScript

<input id="checkOldPassword" type="button" title="Check New Password" value="Check New Password" onclick="checkPassword()" /> <input id="newPassword" type="text" maxlength="8" min="8" /> <script language="javascript"> function checkPassw ...

The head tag specification doesn't properly include the CSS file reference

I have a question regarding my HTML5 web page and the way I am referencing a CSS file in the head tag. Currently, I have it set up like this: <head> <link rel="stylesheet" href="css/style.css" type="text/css"/> </head> However, it d ...