I have navigation menu that contains links,
what I want to achieve is to make the whole li element clickable as a link.
so how to achieve that please?
I'm using bootstrap 3.2 library.
below is the HTML and CSS code.
User wants to able to click on the Link from anywhere inside the li html element
.navbar {
position: relative;
min-height: 40px !important;
margin-bottom: 20px;
border: none !important;
}
#navbarSupportedContent .nav-item {
text-transform: uppercase;
text-align: center;
font-weight: 800;
border-right: 1px solid #01154D;
padding: 10px 24px;
}
#navbarSupportedContent .nav-item:hover {
background-color: #DBDDFD;
color: #000 !important;
}
<div role="navigation">
<div class="container">
<div id="undefined-sticky-wrapper" class="sticky-wrapper" style="height: 42px;"><nav class="navbar navbar-expand-lg navbar-dark bg-primary sticky-top">
<div class="collapse navbar-collapse justify-content-center" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto" style="float:inherit;">
<li class="nav-item active">
<a class="nav-link" href="/webcenter/portal/dummy/pages_en">
<span id="submenu1">Home</span>
</a>
</li>
<li class="nav-item ">
<a class="nav-link" href="/webcenter/portal/dummy/pages_employeetools">
<span id="submenu1">Employee Tools</span>
</a>
</li>
<li class="nav-item ">
<div class="dropdown show">
<a style="color:#e6ecf2;" aria-expanded="false" aria-haspopup="true" class="dropdown-toggle" data-toggle="dropdown" href="#" id="dropdownMenuLink" role="button">MEDIA CENTER</a>
<div aria-labelledby="dropdownMenuLink" class="dropdown-menu">
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/photogallery">PHOTO GALLERY</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/news1">NEWS</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/newpage">dummy MAGAZINE</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/ashurtiassagheer">dummy</a>
</div>
</div>
</li>
<li class="nav-item ">
<a class="nav-link" href="/webcenter/portal/dummy/pages_documents">
<span id="submenu1">Documents</span>
</a>
</li>
<li class="nav-item"><a data-afr-tlen="7" id="T:arabic2" class="nav-link xej" style="font-size: initial;" onclick="this.focus();return false;" data-afr-fcs="true" href="#"><span style="">العربية</span>
<i aria-hidden="true" class="fa fa-language"></i></a>
</li>
<li class="nav-item" style="margin-left: auto;"><span id="T:wcLogoutLink:spacesActionPGL" class="x1a"><a data-afr-tlen="0" id="T:wcLogoutLink:logoutLink" title="Log out of WebCenter Portal" class="nav-link glyphicon glyphicon-log-out xf0 p_AFTextOnly" style="" onclick="this.focus();return false;" data-afr-fcs="true" href="#"></a></span>
</li>
</ul><span id="T:search2" class="x1a">
<div class="navbar-form navbar-left visible-xs" id="searchxs"><div id="T:searchbox2" class="x131" aria-live="polite"><div style="display:none"><a id="T:searchbox2:_afrCommandDelegate" class="xej" onclick="this.focus();return false;" data-afr-fcs="true" href="#"></a></div></div>
</div></span>
</div>
</nav></div>
</div>
</div>
Remove li padding and add width 100% and padding to a tag
li.nav-item > a, li.nav-item > .dropdown show a{
display: block;
width: 100%;
}
.navbar {
position: relative;
min-height: 40px !important;
margin-bottom: 20px;
border: none !important;
}
li.nav-item a{ padding: 10px 0px;}
#navbarSupportedContent .nav-item {
text-transform: uppercase;
text-align: center;
font-weight: 800;
border-right: 1px solid #01154D;
padding: 0px 24px;
}
#navbarSupportedContent .nav-item:hover {
background-color: #DBDDFD;
color: #000 !important;
}
<div role="navigation">
<div class="container">
<div id="undefined-sticky-wrapper" class="sticky-wrapper" style="height: 42px;"><nav class="navbar navbar-expand-lg navbar-dark bg-primary sticky-top">
<div class="collapse navbar-collapse justify-content-center" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto" style="float:inherit;">
<li class="nav-item active">
<a class="nav-link" href="/webcenter/portal/dummy/pages_en">
<span id="submenu1">Home</span>
</a>
</li>
<li class="nav-item ">
<a class="nav-link" href="/webcenter/portal/dummy/pages_employeetools">
<span id="submenu1">Employee Tools</span>
</a>
</li>
<li class="nav-item ">
<div class="dropdown show">
<a style="color:#e6ecf2;" aria-expanded="false" aria-haspopup="true" class="dropdown-toggle" data-toggle="dropdown" href="#" id="dropdownMenuLink" role="button">MEDIA CENTER</a>
<div aria-labelledby="dropdownMenuLink" class="dropdown-menu">
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/photogallery">PHOTO GALLERY</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/news1">NEWS</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/newpage">dummy MAGAZINE</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/ashurtiassagheer">dummy</a>
</div>
</div>
</li>
<li class="nav-item ">
<a class="nav-link" href="/webcenter/portal/dummy/pages_documents">
<span id="submenu1">Documents</span>
</a>
</li>
<li class="nav-item"><a data-afr-tlen="7" id="T:arabic2" class="nav-link xej" style="font-size: initial;" onclick="this.focus();return false;" data-afr-fcs="true" href="#"><span style="">العربية</span>
<i aria-hidden="true" class="fa fa-language"></i></a>
</li>
<li class="nav-item" style="margin-left: auto;"><span id="T:wcLogoutLink:spacesActionPGL" class="x1a"><a data-afr-tlen="0" id="T:wcLogoutLink:logoutLink" title="Log out of WebCenter Portal" class="nav-link glyphicon glyphicon-log-out xf0 p_AFTextOnly" style="" onclick="this.focus();return false;" data-afr-fcs="true" href="#"></a></span>
</li>
</ul><span id="T:search2" class="x1a">
<div class="navbar-form navbar-left visible-xs" id="searchxs"><div id="T:searchbox2" class="x131" aria-live="polite"><div style="display:none"><a id="T:searchbox2:_afrCommandDelegate" class="xej" onclick="this.focus();return false;" data-afr-fcs="true" href="#"></a></div></div>
</div></span>
</div>
</nav></div>
</div>
</div>
Do not render the <li> big, but the <a>. The anchor element already has all the bindings necessary to provide an accessible and very usable link. Rendering it bigger improves usability.
.navbar {
position: relative;
min-height: 40px !important;
margin-bottom: 20px;
border: none !important;
}
#navbarSupportedContent .nav-item {
text-transform: uppercase;
text-align: center;
font-weight: 800;
}
#navbarSupportedContent .nav-link {
display: block;
border-right: 1px solid #01154D;
padding: 10px 24px;
}
#navbarSupportedContent .nav-link:hover {
background-color: #DBDDFD;
color: #000 !important;
}
<div role="navigation">
<div class="container">
<div id="undefined-sticky-wrapper" class="sticky-wrapper" style="height: 42px;">
<nav class="navbar navbar-expand-lg navbar-dark bg-primary sticky-top">
<div class="collapse navbar-collapse justify-content-center" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto" style="float:inherit;">
<li class="nav-item active">
<a class="nav-link" href="/webcenter/portal/dummy/pages_en">
<span id="submenu1">Home</span>
</a>
</li>
<li class="nav-item ">
<a class="nav-link" href="/webcenter/portal/dummy/pages_employeetools">
<span id="submenu1">Employee Tools</span>
</a>
</li>
<li class="nav-item ">
<div class="dropdown show">
<a style="color:#e6ecf2;" aria-expanded="false" aria-haspopup="true" class="dropdown-toggle" data-toggle="dropdown" href="#" id="dropdownMenuLink" role="button">MEDIA CENTER</a>
<div aria-labelledby="dropdownMenuLink" class="dropdown-menu">
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/photogallery">PHOTO GALLERY</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/news1">NEWS</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/newpage">dummy MAGAZINE</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/ashurtiassagheer">dummy</a>
</div>
</div>
</li>
<li class="nav-item ">
<a class="nav-link" href="/webcenter/portal/dummy/pages_documents">
<span id="submenu1">Documents</span>
</a>
</li>
<li class="nav-item"><a data-afr-tlen="7" id="T:arabic2" class="nav-link xej" style="font-size: initial;" onclick="this.focus();return false;" data-afr-fcs="true" href="#"><span style="">العربية</span>
<i aria-hidden="true" class="fa fa-language"></i></a>
</li>
<li class="nav-item" style="margin-left: auto;"><span id="T:wcLogoutLink:spacesActionPGL" class="x1a"><a data-afr-tlen="0" id="T:wcLogoutLink:logoutLink" title="Log out of WebCenter Portal" class="nav-link glyphicon glyphicon-log-out xf0 p_AFTextOnly" style="" onclick="this.focus();return false;" data-afr-fcs="true" href="#"></a></span>
</li>
</ul><span id="T:search2" class="x1a">
<div class="navbar-form navbar-left visible-xs" id="searchxs"><div id="T:searchbox2" class="x131" aria-live="polite"><div style="display:none"><a id="T:searchbox2:_afrCommandDelegate" class="xej" onclick="this.focus();return false;" data-afr-fcs="true" href="#"></a></div></div>
</div></span>
</div>
</nav>
</div>
</div>
</div>
So a simple CSS only solution would be;
Remove the padding from li element.
Make the a tag a block and give it 100% width
.navbar {
position: relative;
min-height: 40px !important;
margin-bottom: 20px;
border: none !important;
}
#navbarSupportedContent .nav-item {
text-transform: uppercase;
text-align: center;
font-weight: 800;
border-right: 1px solid #01154D;
padding: 0;
}
#navbarSupportedContent .nav-item:hover {
background-color: #DBDDFD;
color: #000 !important;
}
#navbarSupportedContent .nav-item a {
display: block;
width: 100%;
padding: 10px 24px; // removed from list and added here for same visual effect
}
<div role="navigation">
<div class="container">
<div id="undefined-sticky-wrapper" class="sticky-wrapper" style="height: 42px;"><nav class="navbar navbar-expand-lg navbar-dark bg-primary sticky-top">
<div class="collapse navbar-collapse justify-content-center" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto" style="float:inherit;">
<li class="nav-item active">
<a class="nav-link" href="/webcenter/portal/dummy/pages_en">
<span id="submenu1">Home</span>
</a>
</li>
<li class="nav-item ">
<a class="nav-link" href="/webcenter/portal/dummy/pages_employeetools">
<span id="submenu1">Employee Tools</span>
</a>
</li>
<li class="nav-item ">
<div class="dropdown show">
<a style="color:#e6ecf2;" aria-expanded="false" aria-haspopup="true" class="dropdown-toggle" data-toggle="dropdown" href="#" id="dropdownMenuLink" role="button">MEDIA CENTER</a>
<div aria-labelledby="dropdownMenuLink" class="dropdown-menu">
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/photogallery">PHOTO GALLERY</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/news1">NEWS</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/newpage">dummy MAGAZINE</a>
<a class="dropdown-item" href="/webcenter/portal/dummy/pages_mediacenter/ashurtiassagheer">dummy</a>
</div>
</div>
</li>
<li class="nav-item ">
<a class="nav-link" href="/webcenter/portal/dummy/pages_documents">
<span id="submenu1">Documents</span>
</a>
</li>
<li class="nav-item"><a data-afr-tlen="7" id="T:arabic2" class="nav-link xej" style="font-size: initial;" onclick="this.focus();return false;" data-afr-fcs="true" href="#"><span style="">العربية</span>
<i aria-hidden="true" class="fa fa-language"></i></a>
</li>
<li class="nav-item" style="margin-left: auto;"><span id="T:wcLogoutLink:spacesActionPGL" class="x1a"><a data-afr-tlen="0" id="T:wcLogoutLink:logoutLink" title="Log out of WebCenter Portal" class="nav-link glyphicon glyphicon-log-out xf0 p_AFTextOnly" style="" onclick="this.focus();return false;" data-afr-fcs="true" href="#"></a></span>
</li>
</ul><span id="T:search2" class="x1a">
<div class="navbar-form navbar-left visible-xs" id="searchxs"><div id="T:searchbox2" class="x131" aria-live="polite"><div style="display:none"><a id="T:searchbox2:_afrCommandDelegate" class="xej" onclick="this.focus();return false;" data-afr-fcs="true" href="#"></a></div></div>
</div></span>
</div>
</nav></div>
</div>
</div>
Simple Solution, Just throw list (li) between the anchor tags (a)
<ul class="navbar-nav mr-auto" style="float:inherit;">
<a class="nav-link" href="/webcenter/portal/dummy/pages_en">
<li class="nav-item active">
<span id="submenu1">Home</span>
</li>
</a>
<a class="nav-link" href="/webcenter/portal/dummy/pages_employeetools">
<li class="nav-item ">
<span id="submenu1">Employee Tools</span>
</li>
</a>
</ul>
Related
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>
How can I align text to the middle in a dropdown menu navbar?
I have this:
I already try to follow snippets but I don't have success.
<ul class="navbar-nav ml-auto">
<li ngbDropdown class="nav-item dropdown">
<a ngbDropdownToggle class="nav-link dropdown-toggle" [routerLink]="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span>menu</span>
<div ngbDropdownMenu class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item">OPTION 1</a>
<hr class="menu-item--division">
<a class="dropdown-item">OPTON 2</a>
<hr class="menu-item--division">
<a class="dropdown-item">OPTION 3</a>
<hr class="menu-item--division">
<a class="dropdown-item">OPTION 4</a>
<hr class="menu-item--division">
<a class="dropdown-item">OPTON 5</a>
</div>
</li>
</ul>
This is my actual code
https://codeply.com/p/zNU5s3kyQl
Use below CSS in your dropdown-item or add d-flex justify-content-center align-items-center classes in each dropdown-item.
.dropdown-item {
display: flex;
justify-content: center;
align-items: center;
}
.dropdown-menu hr {
margin-top: 0;
margin-bottom: 0;
border: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.dropdown-menu a {
height: 53px;
}
.dropdown-item {
text-align: center;
}
.dropdown-item:hover,
.dropdown-item:focus {
color: #16181b;
text-decoration: none;
background-color: #F3F3F3;
text-align: center;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<ul class="navbar-nav ml-auto">
<li ngbDropdown class="nav-item dropdown">
<a ngbDropdownToggle class="nav-link dropdown-toggle" [routerLink]="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span>menu</span>
<div ngbDropdownMenu class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item d-flex justify-content-center align-items-center">OPTION 1</a>
<hr class="menu-item--division">
<a class="dropdown-item d-flex justify-content-center align-items-center">OPTON 2</a>
<hr class="menu-item--division">
<a class="dropdown-item d-flex justify-content-center align-items-center">OPTION 3</a>
<hr class="menu-item--division">
<a class="dropdown-item d-flex justify-content-center align-items-center">OPTION 4</a>
<hr class="menu-item--division">
<a class="dropdown-item d-flex justify-content-center align-items-center">OPTON 5</a>
</div>
</a>
</li>
</ul>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
So I have this weird problem with bootstrap navbar and gallery that it shows shorter on mobile view and not stretched to mobile view. On desktop version is ok and I dont have any of these problems. I have attached a screenshot and also put the code of the navbar and gallery slider down below. Ty !
Navbar :
<nav class="navbar navbar-custom navbar-expand-lg" style="height:60px !important;">
<a class="navbar-brand pull-bs-canvas-left " href="#"><i class="fa fa-bars"></i></a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="navbar-brand" href="#"><img src="img/amazon.png"></a>
</li>
</ul>
<div style="width:88%; position:relative; right: 15px;">
<div class="input-group">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" style="background-color:rgb(218, 218, 218);">
<span id="search_concept">All</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu scrollable-dropdown" role="menu">
<li>Automotive Accesories</li>
<li>Cell Phone Accesories</li>
<li>Computer Accesories</li>
<li>Health and Personal Care</li>
<li>Automotive Accesories</li>
<li>Cell Phone Accesories</li>
<li>Computer Accesories</li>
<li>Health and Personal Care</li>
<li>Automotive Accesories</li>
<li>Cell Phone Accesories</li>
<li>Computer Accesories</li>
<li>Health and Personal Care</li>
<li>Automotive Accesories</li>
<li>Cell Phone Accesories</li>
<li>Computer Accesories</li>
<li>Health and Personal Care</li>
</ul>
</div>
<input type="hidden" name="search_param" value="all" id="search_param">
<input type="text" class="form-control" name="x" id="search" placeholder="Search">
<span class="input-group-btn">
<button class="btn btn-default" type="button" style="background-color: #F3A847;">
<i class="fas fa-search" style="color: black;"></i>
</button>
</span>
</div>
</div>
</div>
<ul class="navbar-nav ml-auto" style="margin-top:10px;">
<li class="nav-item dropdown nav-itemspan">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span>EN</span><i style="font-size:0.903em" class="fal fa-globe"></i>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">English</a>
<a class="dropdown-item" href="#">Hindi</a>
</div>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="sign_in.html"><span style="">Hello. Sign in</span><p style="font-size:14px; margin-top:0px;"><b>Accounts & Lists</b></p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><span style="">Returns</span><p style="font-size:14px; margin-top:0px;"><b>& Orders</b></p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><span style="">Try</span><p style="font-size:14px; margin-top:0px;"><b>Prime</b></p></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><img src="img/cart_0.png" style="margin-top:2px;"></a>
</li>
</ul>
</nav>
<nav class="navbar navbar-custom navbar-expand-lg" style="position:relative; bottom:10px; height: 50px;">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto" style="margin-top:30px;">
<li class="nav-item">
<i class="fal fa-map-marker-alt fa-lg" style="color:white; margin-top:18px;"></i>
</li>
<li class="nav-item nav-itemspan", style="">
<a class="nav-link" href="#"><span style="font-weight:bold; color:white !important;">Hello</span><p style="font-size:14px; position:relative; bottom:6px;"><b>Select your address</b></p></a>
</li>
<li class="nav-item nav-itemspan" style="margin-left:24px;">
<a class="nav-link" href="sale_page.html"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Amazon Pay</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Today's deals</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Best sellers</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Mobiles</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Today's deals</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Best sellers</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Mobiles</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Today's deals</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Best sellers</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Mobiles</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Today's deals</p></a>
</li>
<li class="nav-item nav-itemspan">
<a class="nav-link" href="#"><p style="font-size:14px; margin-top:0px; color: #bfbfbf;">Best sellers</p></a>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<img src="img/jackpot.jpg" style="position:relative; left:35px;">
</ul>
</div>
</nav>
Carousel :
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" style="position:relative; bottom:10px;">
<div class="carousel-item active">
<img src="https://via.placeholder.com/1500x690" class="d-block w-690" alt="...">
</div>
<div class="carousel-item">
<img src="https://via.placeholder.com/1500x690" class="d-block w-690" alt="...">
</div>
<div class="carousel-item">
<img src="https://via.placeholder.com/1500x690" class="d-block w-690" alt="...">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Also, custom carousel css :
.carousel-inner img {
margin: auto;
}
.carousel-control-prev {
margin-left: 80px;
}
.carousel-control-next {
margin-right: 80px;
}
I have found the solution. Its a bit of a faster one which I dont highly recommend but if you are in a pinch like me you should use it. Use width: and the size that you need for your responsive view and after the size put !important;
.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
}
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>