How to set Bootstrap Navbar active class - navbar

I am using Bootrstap 4 and I cannot figure out why my active class is not working. I have followed examples and documentation but I am still having issues figuring out why it is not working.
My head tag conains jquery then popper then bootstrap in index.html.
COMPONENT.HTML
<!--COMPONENT.HTML-->
<nav class="navbar navbar-expand-lg navbar-dark navbar-custom">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTop"
aria-controls="navbarTop" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTop">
<ul class="nav navbar-nav w-100">
<li class="nav-item ml-4">
<a class="nav-link active" data-toggle="collapse" data-target=".navbar-collapse.show"
routerLink="">Home<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item ml-4">
<a class="nav-link" data-toggle="collapse" data-target=".navbar-collapse.show"
routerLink="/landscaping">Landscaping</a>
</li>
<li class="nav-item ml-4">
<a class="nav-link" data-toggle="collapse" data-target=".navbar-collapse.show"
routerLink="/fences-decks">Fences & Decks</a>
</li>
<li class="nav-item ml-4">
<a class="nav-link" data-toggle="collapse" data-target=".navbar-collapse.show"
routerLink="/sprinkler">Sprinklers</a>
</li>
<li class="nav-item ml-4">
<a class="nav-link" data-toggle="collapse" data-target=".navbar-collapse.show"
routerLink="/remodeling">Remodeling</a>
</li>
<li class="nav-item ml-4">
<a class="nav-link" data-toggle="collapse" data-target=".navbar-collapse.show"
routerLink="/concrete">Concrete</a>
</li>
<!-- <li class="nav-item ml-4">
<a class="nav-link" routerLink="/reviews">Google Reviews</a>
</li> -->
<li class="nav-item ml-4">
<a class="nav-link" data-toggle="collapse" data-target=".navbar-collapse.show"
routerLink="/about">About</a>
</li>
<br>
<div class="text-right ml-auto">
<li class="nav-item">
<a class="nav-link text-info" data-toggle="modal" data-target="#emailForm"><span class="material-icons lightgrey">email</span> user#email.com</a>
</li>
<li class="nav-item">
<a class="nav-link text-info" href="tel:1-801-759-4477"><span class="material-icons lightgrey">phone_in_talk</span> 801-759-4477</a>
</li>
</div>
</ul>
<script>
$("#navbarTop .nav .nav-item").on("click", function(){
$(".nav-link").find(".active").removeClass("active");
$(this).addClass("active");
});
</script>
</div>
</nav>

$(document).ready(function() {
$(".nav-item a").click(function() {
let active = $(".active-nav-item")
if (active) {
$(active).removeClass("active-nav-item");
$(this).parent().addClass("active-nav-item");
}
})
})
#topbar {
.topbar-social-list {
display: flex;
list-style: none;
padding: 0;
margin: 0;
text-align: center;
.topbar-social-list-item {
cursor: pointer;
transition: all 0.3s;
i {
transition: all 0.3s;
}
& i:hover {
transition: all 0.3s;
color: white !important;
}
}
}
}
.nav-sec {
background-color: rgb(14, 13, 13) !important;
.dropdown {
&:hover {
.dropdown-menu {
display: block; // left: -10px; border-radius: 0% !important; } } } .nav-list{ .nav-list-item{ transition: all 0.3s; &:hover{ transition: all 0.3s; background-color:
red !important;
a {
color: blue !important;
}
}
}
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section id="topbar" class="bg-dark">
<div class="container">
<div class="row">
<div class="col d-flex p-2">
<div class="topbar-mail me-3">
<i class="fa-solid fa-envelope text-danger"></i>
<span class="text-secondary">
info#example.com
</span>
</div>
<div class="topbar-phone">
<i class="fa-solid fa-mobile text-danger"></i>
<span class="text-secondary">
+1 5589 55488 55
</span>
</div>
</div>
<div class="col d-flex justify-content-end">
<ul class="topbar-social-list align-items-center">
<li class="topbar-social-list-item">
<i class="fa-brands fa-twitter text-secondary text-center me-3"></i>
</li>
<li class="topbar-social-list-item">
<i class="fa-brands fa-facebook text-secondary text-center me-3"></i>
</li>
<li class="topbar-social-list-item">
<i class="fa-brands fa-instagram text-secondary text-center me-3"></i>
</li>
<li class="topbar-social-list-item">
<i class="fa-brands fa-linkedin text-secondary text-center me-3"></i>
</li>
</ul>
</div>
</div>
</div>
</section>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark nav-sec p-0">
<div class="container">
<a class="navbar-brand fs-2 fw-bold" href="#">DAY</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end nav-list" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item nav-list-item p-lg-3 active-nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item nav-list-item p-lg-3">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item nav-list-item p-lg-3">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item nav-list-item dropdown p-lg-3">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown link
</a>
<ul class="dropdown-menu mt-3" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item nav-list-item p-lg-3">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>

Related

Unabe to expand data-toggle dropdown to full width of screen

I'm trying to extend my navbar data-toggle dropdown to the full width of the screen. For some reason, it still leaves white space on the left side when I set the viewport width to 100. I'm using bootstrap and setting a media query in my CSS which I'll show below.
<nav class="navbar navbar-expand-sm navbar-dark fixed-top bg-primary">
<div class="container">
<a class="navbar-brand text-white">Vince Clicks</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggler"
aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse bg-primary" id="navbarToggler">
<ul class="navbar-nav text-center mx-auto mb-2 mb-sm-0">
<li class="nav-item">
<a class="nav-link active" href="#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#skills">Skills</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
<div class="d-none d-sm-flex">
<a class="btn btn-social-icon btn-linkedin" href="#"><i
class="fab fa-2x fa-github-square"></i></a>
<a class="btn btn-social-icon btn-linkedin" href="http://www.linkedin.com/in/"><i
class="fab fa-2x fa-linkedin"></i></a>
</div>
</div>
</div>
</nav>
#media (max-width: 576px){
.navbar-nav{
margin-top: 11px;
max-height: 158px;
width: 100vw
}
.nav-link{
border-top: 1px solid black;
}
}
The .container has left and right padding (x-axis), remove it by adding .px-0 and your example works. There is no need to set the width in your media query.
In the following snippet, in order to compensate for the lost padding
I have added margins to .navbar-brand and .navbar-toggler
with .ms-3 and .me-3, respectively:
#media (max-width: 576px) {
.navbar-nav {
margin-top: 11px;
max-height: 158px;
}
.nav-link {
border-top: 1px solid black;
}
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
<nav class="navbar navbar-expand-sm navbar-dark fixed-top bg-primary">
<div class="container px-0">
<a class="navbar-brand text-white ms-3">Vince Clicks</a>
<button class="navbar-toggler me-3" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggler" aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse bg-primary" id="navbarToggler">
<ul class="navbar-nav text-center mx-auto mb-2 mb-sm-0">
<li class="nav-item">
<a class="nav-link active" href="#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#skills">Skills</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
<div class="d-none d-sm-flex">
<a class="btn btn-social-icon btn-linkedin" href="#"><i class="fab fa-2x fa-github-square"></i></a>
<a class="btn btn-social-icon btn-linkedin" href="http://www.linkedin.com/in/"><i class="fab fa-2x fa-linkedin"></i></a>
</div>
</div>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous"></script>

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>

Increase height of IcoFont

.navbar.height {
min-height: 180px;
}
.navbar.height .nav.navbar-nav {
min-height: 80px;
}
.navbar.height .nav.navbar-nav .nav-item {
min-height: 80px;
}
.navbar.height .nav.navbar-nav .nav-item a {
min-height: 50px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css">
<div class="row">
<div class="col-xl-12 col-lg-12 filter-bar">
<nav class="navbar navbar-light bg-faded">
<ul class="nav navbar-nav">
<li class="nav-item ">
<a class="nav-link icon-list-demo" data-toggle="tab" [routerLink]="['/franchise/customer']" role="tab" aria-expanded="false"
ngbTooltip="Home">
<i class="icofont icofont-home"></i>
</a>
<div class="slide"></div>
</li>
<li class="nav-item" *ngIf="jwtHelperService.isRole(['globaladmin','globaladminro','franchiseadmin'])">
<a class="nav-link text-muted" href="javascript:;" (click)="custBranch1.show()" title="Create New Branch">
<i class="icofont icofont-building"></i>New
</a>
</li>
</ul>
</nav>
<nav class="navbar navbar-light height bg-faded m-b-30">
<ul class="nav navbar-nav">
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link icon-list-demo" data-toggle="tab" [routerLink]="['/franchise/customer/details/dashboard']" role="tab"
aria-expanded="false" ngbTooltip="Dashboard">
<i class="icofont icofont-chart icofont-4x-pie-alt text-muted"></i>
</a>
<div class="slide"></div>
</li>
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link icon-list-demo" data-toggle="tab" [routerLink]="['/franchise/customer/details/dashboard']" role="tab"
aria-expanded="false" ngbTooltip="Dashboard">
<i class="icofont icofont-chart-pie-alt text-muted"></i>
</a>
<div class="slide"></div>
</li>
</ul>
</nav>
</div>
</div>
How can I centre <li> tags in both <nav> tags and increase their IcoFont size?
I tried to add the icofont-4x class to the <i> tag, but it did not work.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css">
<div class="row">
<div class="col-xl-12 col-lg-12 filter-bar">
<nav class="navbar navbar-light bg-faded">
<ul class="nav navbar-nav">
<li class="nav-item ">
<a class="nav-link icon-list-demo" data-toggle="tab" [routerLink]="['/franchise/customer']" role="tab" aria-expanded="false"
ngbTooltip="Home">
<i class="icofont icofont-home"></i>
</a>
<div class="slide"></div>
</li>
<li class="nav-item" *ngIf="jwtHelperService.isRole(['globaladmin','globaladminro','franchiseadmin'])">
<a class="nav-link text-muted" href="javascript:;" (click)="custBranch1.show()" title="Create New Branch">
<i class="icofont icofont-building"></i>New
</a>
</li>
</ul>
</nav>
<nav class="navbar navbar-light height bg-faded m-b-30">
<ul class="nav navbar-nav">
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link icon-list-demo" data-toggle="tab" [routerLink]="['/franchise/customer/details/dashboard']" role="tab"
aria-expanded="false" ngbTooltip="Dashboard">
<i class="icofont icofont-chart icofont-4x-pie-alt text-muted"></i>
</a>
<div class="slide"></div>
</li>
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link icon-list-demo" data-toggle="tab" [routerLink]="['/franchise/customer/details/dashboard']" role="tab"
aria-expanded="false" ngbTooltip="Dashboard">
<i class="icofont icofont-chart-pie-alt text-muted"></i>
</a>
<div class="slide"></div>
</li>
</ul>
</nav>
</div>
</div>
**CSS**
<style>
.navbar.height {
min-height: 180px;
}
.navbar.height .nav.navbar-nav {
min-height: 80px;
}
.navbar.height .nav.navbar-nav .nav-item {
min-height: 80px;
}
.navbar.height .nav.navbar-nav .nav-item a {
min-height: 50px;
}
</style>
You can try this,
.nav-item .icofont{
font-size: 30px;
}
To center li elements horizontally, use justify-content-center on the nav.
To change font-size of a specific element, you need to use CSS.
.font-25px {
font-size: 25px;
}
<i class="icofont icofont-building font-25px"></i>
.font-25px {
font-size: 25px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet"/>
<div class="row">
<div class="col-xl-12 col-lg-12 filter-bar">
<nav class="navbar navbar-light bg-faded justify-content-center font-25px">
<ul class="nav navbar-nav">
<li class="nav-item ">
<a class="nav-link icon-list-demo" data-toggle="tab" [routerLink]="['/franchise/customer']" role="tab" aria-expanded="false" ngbTooltip="Home">
<i class="icofont icofont-home"></i>Home
</a>
<div class="slide"></div>
</li>
<li class="nav-item" *ngIf="jwtHelperService.isRole(['globaladmin','globaladminro','franchiseadmin'])">
<a class="nav-link text-muted" href="javascript:;" (click)="custBranch1.show()" title="Create New Branch">
<i class="icofont icofont-building"></i>New
</a>
</li>
</ul>
</nav>
<nav class="navbar navbar-light height bg-faded m-b-30 justify-content-center font-25px">
<ul class="nav navbar-nav">
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link icon-list-demo" data-toggle="tab" [routerLink]="['/franchise/customer/details/dashboard']" role="tab" aria-expanded="false" ngbTooltip="Dashboard">
<i class="icofont icofont-chart icofont-4x-pie-alt text-muted"></i>Price
</a>
<div class="slide"></div>
</li>
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link icon-list-demo" data-toggle="tab" [routerLink]="['/franchise/customer/details/dashboard']" role="tab" aria-expanded="false" ngbTooltip="Dashboard">
<i class="icofont icofont-chart-pie-alt text-muted"></i>Product
</a>
<div class="slide"></div>
</li>
</ul>
</nav>
</div>
</div>
To make centre li
1) Set .nav-item and .nav to display: inline- block;
2) Set .navbar to text-align: center
.nav-item, ul.nav {
display: inline-block;
}
.navbar {
text-align: center;
}
For icon size, you can increase font-size
i.icofont {
font-size: 20px; // Change as per your requirement
}

Vertical-Alignment of Image in Navbar

I have a website that I am developing utilizing the Bootstrap 4 framework. I am trying to create a navbar with the navbar-brand in the center. I was able to place the navbar-brand in the center with a navbar-nav on each side of the navbar-brand. Please find below the code that I utilized. My issue is that the navbar-brand is vertically aligned in the center of the navbar.
How can I align the navbar-brand to the bottom of the navbar and have the excess stick out at the top of the navbar without adjusting the margins?
#hdrContainer {
background-color: #0a3782;
}
.container {
background-color: inherit;
}
#tblHeader {
width: 100%;
/*font-size: .8125rem;*/
font-size: 1rem;
text-align: right;
color: #ffffff;
font-weight: bold;
}
#tblHeader tr {
height: 50px;
}
.breadcrumb {
background-color: inherit;
margin-bottom: initial;
font-weight: bold;
}
.breadcrumb .active {
color: inherit;
}
#socialbrand {
text-align: right;
}
#mainNavbar {
background-color: gray;
}
#mainNavbar .container .navbar {
position: relative;
z-index: 0;
max-height: 40px;
}
.navbar-brand {
position: relative;
z-index: 1;
margin-right: initial;
}
.form-control {
width: 200px;
}
.btn-outline-navy {
color: #f6b40e;
background-color: transparent;
background-image: none;
border-color: #f6b40e;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
<div id="hdrContainer" class="container-fluid">
<div class="container">
<table id="tblHeader">
<tbody>
<tr>
<td>
<nav aria-label="breadcrumb" role="navigation">
<ol class="breadcrumb">
<li class="breadcrumb-item active" aria-current="page">Commander, Naval Surface Force, US Pacific</li>
</ol>
</nav>
</td>
<td id="socialbrand" style="display: block; padding: .75rem 1rem;">Follow Us |
<i class="fa fa-facebook-square" aria-hidden="true"></i>
<i class="fa fa-twitter-square" aria-hidden="true"></i>
<i class="fa fa-flickr" aria-hidden="true"></i>
<i class="fa fa-wordpress" aria-hidden="true"></i>
<i class="fa fa-youtube-square" aria-hidden="true"></i>
</td>
</tr>
<tr>
<td colspan="2">
<nav class="navbar navbar-light">
<form class="form-inline">
<input class="form-control form-control-sm ml-auto mr-sm-2 float-right" placeholder="Search" aria-label="Search" type="search">
<button class="btn btn-sm btn-outline-navy my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="mainNavbar" class="container-fluid">
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light">
<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" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto mr-auto">
<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>
<!-- Just an image -->
<a class="navbar-brand mr-auto ml-auto" href="#">
<img src="https://getbootstrap.com/assets/brand/bootstrap-solid.svg" alt="" width="75" height="75">
</a>
<ul class="navbar-nav ml-auto mr-auto">
<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="navbarDropdown1" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown1">
<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>
</div>
</nav>
</div>
</div>
The solution below makes use of the various flexbox utility classes available in Bootstrap, described in detail in the docs.
The .navbar-brand got wrapped into <div id="logo"> in order to set it's positioning to absolute, and it's bottom position to 0. That pushes down the logo container to the bottom of the navbar.
Additionally, I've added the .d-none .d-lg-block classes in order to hide the logo when the menu is collapsed.
Available as a CodePen as well.
/* Pushing logo to bottom */
#logo {
position: absolute;
bottom: 0;
}
/* Basic styling to resemble to source */
.navbar {
background-color: gray;
}
#header {
height: 100px;
color: white;
background-color: #0a3782;
display: flex;
justify-content: center;
align-items: center;
}
<div id="header">[header placeholder]</div>
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container">
<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-around" id="navbarSupportedContent">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Features</a>
<a class="nav-item nav-link" href="#">Pricing</a>
<a class="nav-item nav-link disabled" href="#">Disabled</a>
</div>
<div id="logo" class="d-none d-lg-block">
<a class="navbar-brand m-0" href="#">
<img src="http://getbootstrap.com/assets/brand/bootstrap-solid.svg" width="75" height="75" alt="">
</a>
</div>
<div class="navbar-nav">
<a class="nav-item nav-link" href="#">Item 1</a>
<a class="nav-item nav-link" href="#">Item 2</a>
<a class="nav-item nav-link" href="#">Item 3</a>
<a class="nav-item nav-link" href="#">Item 4</a>
</div>
</div>
</div>
</nav>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>

swap divs left right on mobile view

I want to have the header bar with three elements like below
But in mobile view i want menu(toggle-icon) to go left and logo should come middle. I tried push and pull. but that doesn't work for me. Is there anyway i can achieve this?
Here is my code. FYI, I did not add any separate media query yet. Just using the bootstrap classes.
<div class="row d-flex flex-nowrap" style="background-color: #2B3536;">
<div class="col-lg-1 col-md-1 col-sm-2 col-2 align-self-center"><img src="https://dummyimage.com/127x50/2b3536/fff"></div>
<div class="col-lg-8 col-md-9 col-sm-8 col-8 order-sm-first">
<nav class="navbar navbar-fixed-top navbar-toggleable-sm navbar-expand-sm">
<div class="container d-flex flex-row flex-md-nowrap flex-wrap">
<a href="#" class="hidden-md-up mr-3" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false">
<i class="fa fa-bars fa-lg text-white"></i>
</a>
<!--<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>-->
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav header-nav">
<li class="nav-item">
<a class="nav-link" href="#">Menu 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Menu 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Menu 3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Menu 4</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact Us</a>
</li>
<!--<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>-->
</ul>
</div>
</div>
</nav>
</div>
<div class="col-lg-3 col-md-2 col-sm-2 col-2 align-self-center">
<div class="input-group">
<input class="form-control hidden-md-down"
placeholder="I'm looking for">
<div class="input-group-addon top-search-addon"><i class="fa fa-search fa-search-white"></i></div>
</div>
</div>
</div>
you should add media query to style css file
.navbar-brand{
padding-top:8px;
}
.navbar-brand img{
height:35px;
width:35px
}
#media (max-width:767px) {
.navbar-brand{
position: absolute;
left: 40%;
}
}
.navbar-toggle {
float: left;
}
you can view alive demo menu design