Bootstrap 4: external navbar content responsiveness issue - html

I have a Boostrap 4 navbar in Angular application with an external <div> associated. With BS3 everithing works like a charms, but with BS4 some behaviors seems to be changed. In particular i'm having trouble with the .collapse class.
With BS3 when i load the page the external div is shown, but with BS4 it's initially hidden. Moreover with BS3 when i resize the page the exernal div is automatically collapsed together with the navbar, whereas with BS4 it is not.
So my question is: what do i have to do to have the same exact behavior i had with Boostrap 3?
Here is my code:
<nav class="navbar navbar-expand-lg navbar-light px-0 py-0 mb-5">
<div class="container-fluid">
<div class="navbar-header" style="width: 100%">
<button type="button" class="navbar-toggler pull-right my-2" data-toggle="collapse" data-target=".navbar-collapse">
<span class="navbar-toggler-icon"></span>
</button>
<div class="pull-left">
<img src="assets/images/image.png" width="200" height="100">
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="btn welcome"> Benvenuto <strong>{{ this.sessionUsername }}</strong>!</a></li>
<li class="nav-item"><a class="btn link" role="button" [routerLink]="['/login']" (click)="clearSessionStorage()"><i class="fa fa-sign-out"></i> Logout</a></li>
<li class="nav-item"><a class="btn link" role="button" data-toggle="modal" data-target="#changePasswordModal"><i class="fa fa-unlock-alt"></i> Cambio Password</a></li>
</ul>
</div>
</div>
</nav>
=== External div that give me troubles in responsiveness ===
<div class="navbar-collapse collapse col-lg-2 col-md-2 col-sm-3 col-xs-12" style="float: left">
<ul class="nav nav-pills flex-column">
<li class="nav-item" *ngIf="session.isCompanyVisible"><a class="nav-link link" [routerLink]="['./company']"><i class="fa fa-building-o"></i> Società </a></li>
<li class="nav-item" *ngIf="session.isDocTypeVisible"><a class="nav-link link" [routerLink]="['./document-type']"><i class="fa fa-file-text-o"></i> Tipo Documento </a></li>
<li class="nav-item" *ngIf="session.isConfigVisible"><a class="nav-link link" [routerLink]="['./configuration']"><i class="fa fa-cog"></i> Configurazione </a></li>
<li class="nav-item" *ngIf="session.isDomainsVisible"><a class="nav-link link" [routerLink]="['./domains']"><i class="fa fa-dot-circle-o"></i> Domini </a></li>
<li class="nav-item" *ngIf="session.isSignTypeVisible"><a class="nav-link link" [routerLink]="['./signature-type']"><i class="fa fa-pencil"></i> Firme </a></li>
<li class="nav-item" *ngIf="session.isMonitoringVisible"><a class="nav-link link" [routerLink]="['./monitoring']"><i class="fa fa-desktop"></i> Monitoraggio </a></li>
<li class="nav-item" *ngIf="session.isPDAManagementVisible"><a class="nav-link link" [routerLink]="['./pda-management']"><i class="fa fa-mobile fa-lg"></i> Gestione PDA </a></li>
</ul>
</div>

Its because of change in bootstarp's css
So you can solve your issue by apply some css to your external div as i applied in snippet
#media (min-width: 992px){
.external-collapse.navbar-collapse {
display: -webkit-box!important;
display: -ms-flexbox!important;
display: flex!important;
}
}
<script src="http://code.jquery.com/jquery-3.3.1.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light px-0 py-0 mb-5">
<div class="container-fluid">
<div class="navbar-header" style="width: 100%">
<button type="button" class="navbar-toggler pull-right my-2" data-toggle="collapse" data-target=".navbar-collapse">
<span class="navbar-toggler-icon"></span>
</button>
<div class="pull-left">
<img src="assets/images/image.png" width="200" height="100">
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="btn welcome"> Benvenuto <strong>{{ this.sessionUsername }}</strong>!</a></li>
<li class="nav-item"><a class="btn link" role="button" [routerLink]="['/login']" (click)="clearSessionStorage()"><i class="fa fa-sign-out"></i> Logout</a></li>
<li class="nav-item"><a class="btn link" role="button" data-toggle="modal" data-target="#changePasswordModal"><i class="fa fa-unlock-alt"></i> Cambio Password</a></li>
</ul>
</div>
</div>
</nav>
=== External div that give me troubles in responsiveness ===
<div class="external-collapse navbar-collapse collapse col-lg-2 col-md-2 col-sm-3 col-xs-12" style="float: left">
<ul class="nav nav-pills flex-column">
<li class="nav-item" *ngIf="session.isCompanyVisible"><a class="nav-link link" [routerLink]="['./company']"><i class="fa fa-building-o"></i> Società </a></li>
<li class="nav-item" *ngIf="session.isDocTypeVisible"><a class="nav-link link" [routerLink]="['./document-type']"><i class="fa fa-file-text-o"></i> Tipo Documento </a></li>
<li class="nav-item" *ngIf="session.isConfigVisible"><a class="nav-link link" [routerLink]="['./configuration']"><i class="fa fa-cog"></i> Configurazione </a></li>
<li class="nav-item" *ngIf="session.isDomainsVisible"><a class="nav-link link" [routerLink]="['./domains']"><i class="fa fa-dot-circle-o"></i> Domini </a></li>
<li class="nav-item" *ngIf="session.isSignTypeVisible"><a class="nav-link link" [routerLink]="['./signature-type']"><i class="fa fa-pencil"></i> Firme </a></li>
<li class="nav-item" *ngIf="session.isMonitoringVisible"><a class="nav-link link" [routerLink]="['./monitoring']"><i class="fa fa-desktop"></i> Monitoraggio </a></li>
<li class="nav-item" *ngIf="session.isPDAManagementVisible"><a class="nav-link link" [routerLink]="['./pda-management']"><i class="fa fa-mobile fa-lg"></i> Gestione PDA </a></li>
</ul>
</div>

Related

How do I inline a div in navbar element

I am having some problems with my html. I am making a navbar offcanvas. Here is my code:
<nav class="navbar navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand mx-2" href="#">Olau Pla Richart</a>
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasDarkNavbar" aria-controls="offcanvasDarkNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="offcanvas offcanvas-end text-bg-dark" tabindex="-1" id="offcanvasDarkNavbar" aria-labelledby="offcanvasDarkNavbarLabel">
<div class="offcanvas-header">
<h4 class="offcanvas-title" id="offcanvasDarkNavbarLabel">Menu</h4>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
<li class="nav-item">
<h5><a class="nav-link active border-bottom bi bi-house" href="#home"> Home</a></h5>
</li>
<li class="nav-item">
<h5><a class="nav-link border-bottom bi bi-info-circle" href="#about"> About</a></h5>
</li>
<li class="nav-item">
<h5><a class="nav-link border-bottom bi bi-person-lines-fill" href="#contact"> Contact</a></h5>
</li>
<li class="nav-item">
<h5><a class="nav-link border-bottom bi bi-card-heading" href="#"> Blog</a></h5>
</li>
</ul>
</div>
</div>
</div>
<div>
<a>Test</a>
</div>
</nav>
What I am trying to do is get the Test in the same line as Olau Pla Richart. Here is what my code does at the moment:
I tried adding display: inline; and display: inline-block; but I got no change.
You need to move your div, also wrap a and that same div (now span) in a div to not get spaced because bootstrap 5 has this rule .navbar > .container-fluid { ... , justify-content: space-between}
.test {
color: white
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<nav class="navbar navbar-dark bg-dark">
<div class="container-fluid">
<div>
<a class="navbar-brand mx-2" href="#">Olau Pla Richart</a>
<span>
<a class="test" href="#">Test</a>
</span>
</div>
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasDarkNavbar" aria-controls="offcanvasDarkNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="offcanvas offcanvas-end text-bg-dark" tabindex="-1" id="offcanvasDarkNavbar" aria-labelledby="offcanvasDarkNavbarLabel">
<div class="offcanvas-header">
<h4 class="offcanvas-title" id="offcanvasDarkNavbarLabel">Menu</h4>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
<li class="nav-item">
<h5><a class="nav-link active border-bottom bi bi-house" href="#home"> Home</a></h5>
</li>
<li class="nav-item">
<h5><a class="nav-link border-bottom bi bi-info-circle" href="#about"> About</a></h5>
</li>
<li class="nav-item">
<h5><a class="nav-link border-bottom bi bi-person-lines-fill" href="#contact"> Contact</a></h5>
</li>
<li class="nav-item">
<h5><a class="nav-link border-bottom bi bi-card-heading" href="#"> Blog</a></h5>
</li>
</ul>
</div>
</div>
</div>
</nav>
Try border-bottom (border-bottom: 1px solid #ccc)
details
Try adding display: flex; to your navbar class.
You do not need any additional CSS, You just need to place the a in the the proper place (after .navbar-brand), and add .navbar-text to get the correct color for .navbar-dark/.navbar-light. It will be centered between .navbar-brand and .navbar-toggler by default. You can use .me-auto to left-align it, or .ms-auto to right-align.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<nav class="navbar navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand mx-2" href="#">Olau Pla Richart</a>
<a class="navbar-text ms-auto me-2">Test</a>
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasDarkNavbar" aria-controls="offcanvasDarkNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="offcanvas offcanvas-end text-bg-dark" tabindex="-1" id="offcanvasDarkNavbar" aria-labelledby="offcanvasDarkNavbarLabel">
<div class="offcanvas-header">
<h4 class="offcanvas-title" id="offcanvasDarkNavbarLabel">Menu</h4>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
<li class="nav-item">
<h5><a class="nav-link active border-bottom bi bi-house" href="#home"> Home</a></h5>
</li>
<li class="nav-item">
<h5><a class="nav-link border-bottom bi bi-info-circle" href="#about"> About</a></h5>
</li>
<li class="nav-item">
<h5><a class="nav-link border-bottom bi bi-person-lines-fill" href="#contact"> Contact</a></h5>
</li>
<li class="nav-item">
<h5><a class="nav-link border-bottom bi bi-card-heading" href="#"> Blog</a></h5>
</li>
</ul>
</div>
</div>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>

Bootstrap 5 Navbar collapse and dropdown

I'm having a little trouble with my navbar, using bootstrap 5. The navbar doesn't collapse after expanding and the dropdown list doesn't drop.
<!-- Bootstrap-5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- Body -->
<nav class="navbar navbar-expand-md bg-light sticky-top">
<div class="container-fluid ">
<a class="navbar-brand" href="#"><img class="" width="100px" src="icons/cake/Asset 4.png"></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#collapsibleNavbar">
<span class="fa fa-navicon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" href="#">SERVICES</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Delivery</a></li>
<li>
<a class="dropdown-item" href="#">Event Planning</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><button class="btn btn-danger">ORDER ONLINE</button></a>
</li>
</ul>
</div>
</div>
</nav>
Many of Bootstrap's components require the use of JavaScript to function. Including navbars and dropdowns. I added the relevant source for both font-awesome and the Bootstrap JS.
Read more here on Bootstrap 5 Introduction.
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<nav class="navbar navbar-expand-md bg-light sticky-top">
<div class="container-fluid ">
<a class="navbar-brand" href="#"><img class="" width="100px" src="icons/cake/Asset 4.png"></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#collapsibleNavbar">
<span class="fa fa-navicon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" href="#">SERVICES</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Delivery</a></li>
<li>
<a class="dropdown-item" href="#">Event Planning</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><button class="btn btn-danger">ORDER ONLINE</button></a>
</li>
</ul>
</div>
</div>
</nav>

Bootstrap 4 navbar/menu keep entry visible when collapsed

This is a question similar to this one, but it is for Bootstrap 4.
I am not able to add right-justified entries on the BS4 navbar that stay visible both when collapsed and not collapsed. I spent one full afternoon without success.
This is my goal:
Here my current code (that works only when not collapsed):
<nav class="navbar navbar-light navbar-expand-xl border-bottom mainmenu sticky-top">
<a class="navbar-brand text-capitalize text-blur" href="/">
<img class="mr-1" src="/images/logo/favicon-32x32.png" alt="Logo">
<span class="">Portami in Pista</span>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#myTopMenu"
aria-controls="collapsableTopMen" aria-expanded="false" aria-label="[Menu]">
<span class="sr-only">[Menu]</span>
<span class="navbar-toggler-icon" title="[Menu]"/>
</button>
<div class="collapse navbar-collapse" id="collapsableTopMen">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="/Schools/">
<i class="fa fa-motorcycle fa-rotate-315 text-danger" aria-hidden="true"/>
<span class="text-blur-danger">PiP Reparto Corse</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/Tracks/">
<i class="fa fa-flag-checkered text-primary" aria-hidden="true"/>
<span>Piste</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/Blog/le-guide-del-giovedi/">
<i class="fa fa-mortar-board text-primary" aria-hidden="true"/>
<span>Le guide del giovedì</span>
</a>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<!- START of section should be always visible -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownLang" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="famfamfam-flags it" title="Italiano"/>
<span class="d-inline d-xl-none">Italiano</span>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownLang">
<a class="dropdown-item" href="/AbpLocalization/ChangeCulture?cultureName=en&returnUrl=/">
<i class="famfamfam-flags gb" aria-hidden="true"/>
<span class="">English</span>
</a>
</div>
</li>
<!- END of section should be always visible -->
<li class="nav-item">
<a class="nav-link" href="/Account/Login"><i class="fa fa-sign-in"/> Log in</a>
</li>
</ul>
</div>
</nav>
Since you're using Bootstrap 4, this answer is more relevant to your question:
https://stackoverflow.com/a/41513784/171456 (see the last part)
The part that you always want to keep visible needs to be separate from any of the collapsible parts. Then use the order-* classes to position the items as desired:
Demo: https://codeply.com/p/ylDhhZtpiH
<nav class="navbar navbar-light navbar-expand-xl border-bottom mainmenu sticky-top justify-content-start">
<a class="navbar-brand text-capitalize text-blur" href="/">
<img class="mr-1" src="//placehold.it/32" alt="Logo">
<span class="">Portami in Pista</span>
</a>
<button class="navbar-toggler order-2 ml-1" type="button" data-toggle="collapse" data-target=".collapsable" aria-controls="collapsableTopMen" aria-expanded="false" aria-label="[Menu]">
<span class="sr-only">[Menu]</span>
<span class="navbar-toggler-icon" title="[Menu]"></span>
</button>
<!-- 1st collapse menu -->
<div class="collapse navbar-collapse collapsable flex-grow-0 flex-xl-grow-1 order-last" id="collapsableTopMen">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="/Schools/">
<i class="fa fa-motorcycle fa-rotate-315 text-danger" aria-hidden="true"></i>
<span class="text-blur-danger">PiP Reparto Corse</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/Tracks/">
<i class="fa fa-flag-checkered text-primary" aria-hidden="true"></i>
<span>Piste</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/Blog/le-guide-del-giovedi/">
<i class="fa fa-mortar-board text-primary" aria-hidden="true"></i>
<span>Le guide del giovedì</span>
</a>
</li>
</ul>
</div>
<!-- always visible portion -->
<ul class="navbar-nav order-1 order-xl-last ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownLang" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-flag it" title="Italiano"></i>
<span class="d-inline d-xl-none">Italiano</span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownLang">
<a class="dropdown-item" href="#">
<i class="fas fa-flag-usa gb" aria-hidden="true"></i>
<span class="">English</span>
</a>
</div>
</li>
</ul>
<!-- 2nd collapse menu -->
<div class="collapse navbar-collapse collapsable flex-grow-0 order-last">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/Account/Login"><i class="fa fa-sign-in"></i> Log in</a>
</li>
</ul>
</div>
</nav>
https://codeply.com/p/ylDhhZtpiH
I did a small important fix to the good answer from Zim.
I fixed the "always visible" portion of the menu as he did not overlap the whole menu when it was collapsed.
Adding a custom .navbar-always-overlapped class, fixed it.
<nav class="navbar navbar-light navbar-expand-lg border-bottom mainmenu sticky-top justify-content-start">
<!-- same code from Zim here>
...
<!-- always visible portion. Note the 'navbar-always-overlapped' -->
<ul class="navbar-nav navbar-always-overlapped order-1 order-lg-last ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownLang" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-flag it" title="Italiano"></i>
<span class="d-inline d-lg-none">Italiano</span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownLang">
<a class="dropdown-item" href="#">
<i class="fas fa-flag-usa gb" aria-hidden="true"></i>
<span class="">English</span>
</a>
</div>
</li>
</ul>
<!-- 2nd collapse menu -->
<div class="collapse navbar-collapse collapsable flex-grow-0 order-last">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/Account/Login"><i class="fa fa-sign-in"></i> Log in</a>
</li>
</ul>
</div>
</nav>
and the code for .navbar-always-overlapped:
.navbar-always-overlapped .dropdown-menu {
position: absolute !important;
}
See https://codeply.com/p/9deLYTGblZ

How to navigate trough tabs HTML

I am new with HTML and i downloaded a template that uses Tabs and this is how is rendered:
So What I need is to when I click on "Próximo" it changes the tabs to the next or other that I choose.
I tried to do something like that, but it didn't worked! :
<button type="button" class="btn btn-danger nav-link" aria-expanded="true" href="#Legal" data-toggle="tab">
Próximo
</button>
The code :
<ul class="nav nav-tabs mb-3">
<li class="nav-item">
<a href="#CompanyData" data-toggle="tab" aria-expanded="false" class="nav-link active">
<i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
<span class="d-none d-lg-block">Dados da Empresa</span>
</a>
</li>
<li class="nav-item">
<a href="#Legal" data-toggle="tab" aria-expanded="true"
class="nav-link">
<i class="mdi mdi-account-circle d-lg-none d-block mr-1"></i>
<span class="d-none d-lg-block">Cadastrar Empresa</span>
</a>
</li>
<li class="nav-item">
<a href="#listCompanies" data-toggle="tab" aria-expanded="false" class="nav-link">
<i class="mdi mdi-settings-outline d-lg-none d-block mr-1"></i>
<span class="d-none d-lg-block">Listar Empresas</span>
</a>
</li>
</ul>
And
<div class="tab-content">
<div class="tab-pane show active" id="CompanyData">
</div>
<div class="tab-pane " id="Legal">
</div>
<div class="tab-pane" id="listCompanies">
</div>
</div>
You can't make another buttons do the task of a tab button because internally bootstrap.js makes several changes to it. But what we can do is to simulate the click event and make the tab button click if we click our button.
Add a callback function on a click to our button as below
<button onclick="makeClick()" type="button" class="btn btn-danger nav-link" aria-expanded="true" href="#Legal" data-toggle="tab">
Próximo
</button>
Assign id to each li in list
<ul class="nav nav-tabs mb-3">
<li class="nav-item" >
<a href="#CompanyData" id="Dados" data-toggle="tab" aria-expanded="false" class="nav-link active">
<i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i><span class="d-none d-lg-block">Dados da Empresa</span>
</a>
</li>
<li class="nav-item">
<a href="#Legal" id="Cadastrar" data-toggle="tab" aria-expanded="true"
class="nav-link">
<i class="mdi mdi-account-circle d-lg-none d-block mr-1"></i><span class="d-none d-lg-block">Cadastrar Empresa</span>
</a>
</li>
<li class="nav-item">
<a href="#listCompanies" id="Listar" data-toggle="tab" aria-expanded="false" class="nav-link">
<i class="mdi mdi-settings-outline d-lg-none d-block mr-1"></i><span class="d-none d-lg-block">Listar Empresas</span>
</a>
</li>
And in your JS file create the below function:
makeClick(){
$('#Listar').click(); //this will simulate the click and Listar tab will be opened
}
Code:
function makeClick() {
$('#Cadastrar').click();
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js" integrity="sha384-6khuMg9gaYr5AxOqhkVIODVIvm9ynTT5J4V1cfthmT+emCG6yVmEZsRHdxlotUnm" crossorigin="anonymous"></script>
<ul class="nav nav-tabs mb-3">
<li class="nav-item">
<a href="#CompanyData" id="Dados" data-toggle="tab" aria-expanded="false" class="nav-link active">
<i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i><span class="d-lg-block"> Dados da Empresa </span>
</a>
</li>
<li class="nav-item">
<a href="#Legal" id="Cadastrar" data-toggle="tab" aria-expanded="true" class="nav-link">
<i class="mdi mdi-account-circle d-lg-none d-block mr-1"></i><span class="d-lg-block">Cadastrar Empresa</span>
</a>
</li>
<li class="nav-item">
<a href="#listCompanies" id="Listar" data-toggle="tab" aria-expanded="false" class="nav-link">
<i class="mdi mdi-settings-outline d-lg-none d-block mr-1"></i><span class="d-lg-block">Listar Empresas</span>
</a>
</li>
<div class="tab-content">
<div class="tab-pane show active" id="CompanyData" role="tabpanel">
Dados da Empresa Tab
<button onclick="makeClick()" type="button" class="btn btn-danger nav-link" aria-expanded="true" href="#Legal" data-toggle="tab">Próximo
</button>
</div>
<div class="tab-pane " id="Legal" role="tabpanel">
Cadastrar Empresa Tab
</div>
<div class="tab-pane" id="listCompanies" role="tabpanel">
Listar Empresas Tab
</div>
</div>

Bootstrap 4 Navbar align content left, center and right [duplicate]

This question already has answers here:
Bootstrap NavBar with left, center or right aligned items
(14 answers)
Center an element in Bootstrap Navbar
(10 answers)
Closed 4 years ago.
I need to achieve the brand logo in left, menu items to be center and couple of buttons in the right. I have tried using the flexbox approach but the center items does not align well. and also the brand logo has a wide space with a clickable link.
JS Fiddle
<nav class="navbar navbar-light navbar-expand-md bg-faded justify-content-center">
<div class="container">
<img src="assets/logo/" alt="logo">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse w-100 ml-auto" id="collapsingNavbar3">
<ul class="navbar-nav w-100 justify-content-center">
<li class="nav-item active">
<a class="nav-link" href="#">How it works</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Become a tutor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto w-100 justify-content-end">
<li class="nav-item">
<a class="btn btn-link" href="#">Sign In</a>
</li>
<li class="nav-item">
<a class="btn btn-primary" href="#">Sign Up</a>
</li>
</ul>
</div>
</div>
</nav>
Answering my own question few months later.
<nav class="navbar navbar-light navbar-expand-md bg-white justify-content-center main--navigation dark-header">
<a href="#" class="navbar-brand d-flex w-50 mr-auto">
<img src="assets/images/logo-header.svg" class="navigation__logo" alt="Logo" />
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse w-100" id="collapsingNavbar">
<ul class="navbar-nav w-100 justify-content-center">
<li class="nav-item active">
<a class="nav-link" href="#">Browse</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">How it works</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Become a tutor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Prices</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto w-100 justify-content-end">
<li class="nav-item dropdown no-arrow mx-1 nav-link px-0">
<button id="bookmarksDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" type="button" class="btn btn-outline-secondary btn-outlined" data-original-title="Bookmarks"><img src="assets/icons/bookmark-header-dark.svg"></button>
<div class="dropdown-list dropdown-menu dropdown-menu-right" aria-labelledby="alertsDropdown">
<h6 class="dropdown-header">
Bookmarks
</h6>
</div>
</li>
<li class="nav-item dropdown no-arrow mx-1 nav-link px-0">
<button id="messagesDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" type="button" class="btn btn-outline-secondary btn-outlined" data-original-title="Notifications"><img src="assets/icons/bell-header-dark.svg"></button>
<div class="dropdown-list dropdown-menu dropdown-menu-right" aria-labelledby="notificationsDropdown">
<h6 class="dropdown-header">
You do not have any notifications yet
</h6>
</div>
</li>
<li class="nav-item dropdown no-arrow mx-1 ml-3 mr-0 nav-link px-0">
<a class="nav-link dropdown-toggle pr-0" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div class="header__profile__title d-inline-block text-right align-middle">
<span class="mr-2 d-none d-block header__profile__name">Aaron Alexander</span>
<span class="mr-2 d-none d-block header__profile__role">Student</span>
</div>
<div class="header__profile d-inline-block">
<img class="img-profile rounded" src="assets/images/andrew-franklin.jpeg" alt="Aaron Alexander">
</div>
</a>
<div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
<a class="dropdown-item" href="#">
<i class="fas fa-user fa-sm fa-fw mr-2"></i>
Profile
</a>
<a class="dropdown-item" href="#">
<i class="fas fa-cogs fa-sm fa-fw mr-2"></i>
Settings
</a>
<a class="dropdown-item" href="#">
<i class="fas fa-list fa-sm fa-fw mr-2"></i>
Activity Log
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
<i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
Logout
</a>
</div>
</li>
</ul>
</div>
</nav>
That container div you added after the nav makes you loose the flexbox attributes.
You also set the logo with the class "w-100" which takes all possible width.
I removed those and got a nicely aligned navbar.
<nav class="navbar navbar-light navbar-expand-md bg-faded justify-content-center align-items-center">
<img src="assets/logo/" alt="logo">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse w-100 ml-auto" id="collapsingNavbar3">
<ul class="navbar-nav w-100 justify-content-center">
<li class="nav-item active">
<a class="nav-link" href="#">How it works</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Become a tutor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto w-100 justify-content-end">
<li class="nav-item">
<a class="btn btn-link" href="#">Sign In</a>
</li>
<li class="nav-item">
<a class="btn btn-primary" href="#">Sign Up</a>
</li>
</ul>
</div>
</nav>
Here's a fiddle with the results.
here is my working example.
You just need to put all content into single div in order to Justify content with bootstrap classes. Also, I am using navbar-brand and making them show hide depending on screen resolution. You can do that with js which might be smoother once the page loads completely.
#media only screen and (max-width: 991px) {
.logo {
display: flex;
}
.collapse .navbar-brand {
display: none
}
}
#media only screen and (min-width: 992px) {
.logo {
display: none;
}
.collapse .navbar-brand {
display: none;
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light d-flex ">
<a class="navbar-brand logo" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-between" id="navbarSupportedContent">
<a class="navbar-brand" href="#">Navbar</a>
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>