Bootstrap 4 menu not opening other dropdowns - html

Because I am trying to get the Text to remain a link and the dropdown toggle to open the dropdown, which, I've managed to achieve. But it causing Dropdown-2 to toggle/open Dropdown-1. And only Dropdown-1 is working.
Basically, can't figure out why its only opening Dropdown-1 only which ever Dropdown I click
I'm using Bootstrap 4.4.1
You can see the Pen here https://codepen.io/cr8tivly/pen/MWavBJr
This is the markup
<nav class="navbar navbar-expand-lg navbar-light">
<ul class="row row-cols-4 navbar-nav main relative list-unstyled col-6">
<li class="col nav-item dropdown" data-toggle="dropdown" aria-expanded="false">
<a class="" href="http://google.com">Dropdown-1</a>
<ul class="dropdown-menu">
<li>item-1-one</li>
<li>item-2-one</li>
<li>item-3-one</li>
<li>item-4-one</li>
</ul>
</li>
<li class="col nav-item dropdown" data-toggle="dropdown" aria-expanded="false">
<a class="" href="http://google.com">Dropdown-2</a>
<ul class="dropdown-menu">
<li>item-1-two</li>
<li>item-2-two</li>
<li>item-3-two</li>
<li>item-4-two</li>
</ul>
</li>
<li class="col">Three</li>
<li class="col">Four</li>
</ul>
</nav>

The problem is data-toggle="dropdown" should be on the a. Check the documentation here.
Instead of:
<li class="col nav-item dropdown" data-toggle="dropdown" aria-expanded="false">
<a>Dropdown-1</a>
Use:
<li class="col nav-item dropdown" aria-expanded="false">
<a data-toggle="dropdown">Dropdown-1</a>
Updated pen here.

If you want the plus sign to open the dropdown and the text to open a link you can do this:
<li class="col nav-item">
<div class="d-flex">
<a class="btn btn-link" href="http://google.com">Dropdown-2</a>
<button class="btn btn-light dropdown" id="d2" data-toggle="dropdown" aria-expanded="false">+</button>
<ul class="dropdown-menu" aria-labelledby="d2">
<li>item-1-two</li>
<li>item-2-two</li>
<li>item-3-two</li>
<li>item-4-two</li>
</ul>
</div>
</li>

Related

Having issues getting Angular Routing to work properly

I'm pretty sure I have the routing setup correctly within my application because when I type the correct path it takes me to and displays the correct information. Where I am having issues is the router link. I believe it has something to do with the HTML? When I click on each link nothing happens. Anyways I will post the HTML to see if someone can point out something I may be doing wrong. I've also got the github repository link here: https://github.com/jadenadams329/JIT1
<div class="app-bar-navbar vertical-appbar">
<nav class="navbar navbar-expand-lg navbar-dark bg-primary app-bar-section pr-0 d-flex justify-content-start">
<button class="navbar-toggler1 m-0 focusable" (click)="displaySideNav =!displaySideNav;" (blur)="displaySideNav = false">
<i class="icon-menu-bold"></i>
</button>
<span class="vertical-line-seperator left"> </span>
<div class="navbar-brand d-flex align-items-center">
<img src="assets/images/logo/secondary-logo-site.svg" class="logo-img">
<!-- <i class="icon-bd-logo-bold"></i> -->
<span class="brand-name">JIT Management Console</span>
</div>
<div class="navbar-right-content justify-content-end d-flex">
<div class="navbar-right-toggle d-flex">
<ul class="navbar-nav">
<li class="nav-item dropdown-appbar d-flex">
<span class="vertical-line-seperator left"> </span>
<a class="nav-link navbar-toggler" id="navbarDropdownMenuLink" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="icon-more-bold text-white rotate-90"></i>
</a>
<ul class="dropdown-menu pull-right" aria-labelledby="dLabe2">
<li role="separator" class="dropdown-divider"></li>
<li class="nav-item">
Sign Out
</li>
</ul>
</li>
</ul>
</div>
<div class="custom-dropdown d-flex">
<ul class="navbar-nav">
<li class="nav-item dropdown-appbar d-flex">
<span class="vertical-line-seperator left"> </span>
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Admin
</a>
<ul class="dropdown-menu pull-right" aria-labelledby="dLabe2">
<li>
Sign Out
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section class="vertical-sidebar collapse navbar-collapse justify-content-end" id="navbarSidebarContent-main"
[ngClass]="{'show':displaySideNav}">
<nav class="nav">
<ul class="sidebar-links">
<li>
<a routerLink="/home">Home</a>
</li>
<li>
<a routerLink="/manage-sessions">Manage Sessions</a>
</li>
<li>
<a routerLink="/export-scancodes">Export ScanCodes</a>
</li>
<li>
<a routerLink="/imu-data">IMU Data</a>
</li>
<li>
<a routerLink="/global-order-days">Global Order Days</a>
</li>
<li>
<a routerLink="/order-exception-report">Order Exception Report</a>
</li>
</ul>
</nav>
</section>
</div>
<div>
<router-outlet></router-outlet>
</div>
What I expect to happen is when I click on the links that it shows the correct view so I do not have to type in the path each time.
You have blur event in button element. Currently It's removing the section element whenever you are focused out of button. remove that blur event from button and place click event on ui element and set the displaySidenav to false.
<button class="navbar-toggler1 m-0 focusable" (click)="displaySideNav =!displaySideNav;" >
<i class="icon-menu-bold"></i>
</button>
<ul class="sidebar-links" (click)="displaySideNav = false">
<li>
<a routerLink="/home">Home</a>
</li>
<li>
<a routerLink="/manage-sessions">Manage Sessions</a>
</li>
<li>
<a routerLink="/export-scancodes">Export ScanCodes</a>
</li>
<li>
<a routerLink="/imu-data">IMU Data</a>
</li>
<li>
<a routerLink="/global-order-days">Global Order Days</a>
</li>
<li>
<a routerLink="/order-exception-report">Order Exception Report</a>
</li>
</ul>

Bootstrap 4 Navbar: right-aligned dropdown menu opens on the right: overflow [duplicate]

This question already has answers here:
Bootstrap 4: Dropdown menu is going off to the right of the screen
(6 answers)
Closed 4 years ago.
I am using Bootstrap 4 for a very simple navbar, I just noticed that my right-aligned dropdown opens... on the right which creates an overflow (ie. the horizontal scrollbar of the webbrowser is showing up).
This is the code the navbar:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbarNavDropdown" class="navbar-collapse collapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Recipes</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Shopping List</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown">
Manage
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Save Data</a>
<a class="dropdown-item" href="#">Fetch Data</a>
</div>
</li>
</ul>
</div>
</nav>
And the related codepen: https://codepen.io/ehouarn-perret/pen/MLoGdE
How to make that right-aligned dropdown to open the menu on the left?
Add dropdown-menu-right to your dropdown-menu class, like this:
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#">Save Data</a>
<a class="dropdown-item" href="#">Fetch Data</a>
</div>
This will align your dropdown menu to the right, instead of the default that is to the left.
Try This :
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbarNavDropdown" class="navbar-collapse collapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Recipes</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Shopping List</a>
</li>
</ul>
<ul class="navbar-nav dropleft">
<li class="dropdown">
<a class="nav-link dropdown-toggle " href="#" id="navbarDropdownMenuLink" data-toggle="dropdown">
Manage
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Save Data</a>
<a class="dropdown-item" href="#">Fetch Data</a>
</div>
</li>
</ul>
</div>
At the moment, the _dropdown.scss of Bootstrap is setting left: 0px to .dropdown-menu.
If you add the below to your CSS, it should override this.
.dropdown-menu {
right: 0px;
left: auto;
}
Perhaps add a unique class and target that so that you don't break anything else.
according to Dropdown menu causes scrollbar
adding dropdown-menu-right to your dropdown-menu should do the trick

Bootstrap 4 navbar dropdown height is different

I'm using a bootstrap navbar with a dropdown for the user menu.
The issue
I'm using this navbar as a blade template in laravel. On some pages the dropdown menu has the dimensions 160x63.39px and on some other pages 160x49px.
But the source code is the same on every page.
Does anybody know what reasons this issue could have?
Source
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="http://127.0.0.1">Tool</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="http://127.0.0.1/dashboard">Dashboard</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown">Ticketsystem</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="http://127.0.0.1/tickets/new">Neues Ticket</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="http://127.0.0.1/tickets">Alle Tickets</a>
</div>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-expanded="false">User</a>
<div class="dropdown-menu">
<form action="http://127.0.0.1/logout" method="post">
<input type="hidden" name="_token" value="#CSRF_TOKEN#">
<button type="submit" class="dropdown-item">Logout</button>
</form>
</div>
</li>
</ul>
</div>
</div>
</nav>
This is because different browsers have default CSS on some elements.
Best way to remove this is to add this CSS to your code:
* {
margin: 0;
padding: 0;
}
Or to use necolas.github.io/normalize.css

Positioning of image and panel in the header in HTML

The script generates a header Panel for my webpage which is displayed here:
I want the OcC field to begin at the intersection of vertical and horizontal bar as shown. I am sure a margin: attribute can help me but don't know where to use it. Please help me and thanks.
<header>
<img src="C:/D DRIVE DATA/generic/logo.png" height="43" width="130">
height="43" width="130">
<div class="container">
<div class="row">
<nav class="navbar main-nav navbar-default ">
<div class="navbar-collapse collapse" id="navbar">
<ul class="nav navbar-nav">
<li class="dropdown OcC">
<a class="dropdown-toggle" data-close-others="false" data-delay="100" data-
hover="dropdown" data-toggle="dropdown" href="javascript:;">OcC </a>
</li>
<li class="dropdown CoO ">
<a class="dropdown-toggle" data-close-others="false" data-delay="100" data-
hover="dropdown" data-toggle="dropdown" href="javascript:;">CoO </a>
</li>
<li class="dropdown Fccc">
<a class="dropdown-toggle" data-close-others="false" data-delay="100" data-
hover="dropdown" data-toggle="dropdown" href="javascript:;">Fccc</a>
</li>
<li class="dropdown mpP">
<a class="dropdown-toggle" data-close-others="false" data-delay="100" data-
hover="dropdown" data-toggle="dropdown" href="javascript:;">mpP</a>
</li>
<li class="dropdown iR">
<a class="dropdown-toggle" data-close-others="false" data-delay="100" data-
hover="dropdown" data-toggle="dropdown" href="javascript:;">iR</a>
</li>
<li class="dropdown jko">
<a class="dropdown-toggle" data-close-others="false" data-delay="100" data-
hover="dropdown" data-toggle="dropdown" href="javascript:;">jko</a>
</li></ul></li></ul></div></nav></div></div></header>

How to set dropdown on hover in this templete boostrap4

I Use this template, build with boostrap4
Can you help me to add Hover DropDown Menubar in this above template ?
I update index.html file with some code to show Dropdown menubar, now its shown, but I need to show menu on hover.
Here Is Code:
<!-- Navigation -->
<nav class="navbar fixed-top navbar-toggleable-md navbar-inverse bg-inverse">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarExample" aria-controls="navbarExample" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="container">
<a class="navbar-brand" href="/"><img src="img/km-logo.png" style="margin-bottom:5px;" width="60%" height="auto" alt="kmwebsoft.com logo"></a>
<div class="collapse navbar-collapse dropdown" id="navbarExample">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="dropdown">
<li class="dropdown"> Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li class="dropdown-item">Action</li>
<li class="dropdown-item">Another action</li>
<li class="dropdown-item">Something else here</li>
</ul>
</li>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<span class="text-primary"></span>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
Can you suggest any idea ? I apply menu on AboutUs temporary.
You Have to use javascript or jquery to do this.bind event on the menu item where you want dropdown menu.