Too small mobile view in boostrap 4 - html

Goog morning,
I look forn an solution to create bigger and more visible mobile view for my bootrstap menu with language switcher. Everything is based on boostrap 4. Ive never tried to write something in bootstrap...
Any help??
`
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/"
crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.2.1/css/flag-icon.min.css">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style type="text/css">
.phone-link {
border-radius: 25px;
background-color: lightblue;
color: #ffffff;
padding: 15px 25px;
}
.navbar-nav {
margin-right: 40px;
}
.navbar-nav .nav-item {
padding: 25px;
}
#media (max-width: 999px) {
.phone-link {
display: none;
}
}
.dropdown.language {
position: absolute;
right: 150px;
width: auto;
top: 35px;
}
#media (max-width: 991px) {
.dropdown.language {
right: 100px;
position: absolute; top: 10px;
}
}
</style>
<nav class="navbar navbar-light" style="background-color: #e3f2fd; ">
<a class="navbar-brand" href="#">
<img src="https://getbootstrap.com/docs/4.2/assets/brand/bootstrap-solid.svg" width="30" height="75" alt="">
</a>
<button class="navbar-toggler" 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">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink" style="position: absolute; left: 0px; top: 76px">
<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 class="dropdown language">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="width: 160; height: 42">
<span class="flag-icon flag-icon-us"></span> English
</button>
<div class="dropdown-menu dropdown-menu-left text-left language">
<p style="text-align: left !important">
<a class="dropdown-item" href="#fr"><span class="flag-icon flag-icon-fr"> </span> French</a>
<a class="dropdown-item" href="#it"><span class="flag-icon flag-icon-it"> </span> Italian</a>
<a class="dropdown-item" href="#ru"><span class="flag-icon flag-icon-ru"> </span> Russian</a>
</div>
</div>
</nav>
`
Mobile view is too small... I want to make elements more bigger and viisble

Related

How to make my shopping cart and favorites button responsive

I have a shopping cart and favorites button in my boostrap nav-bar. When I hit 992 px the navbar switches to a hamburger collapse menu which is fine for the dropdown in my navbar but it makes my cart and favorites button spread out. I need help displaying these buttons from the dropdown in a way that makes sense for the user on tablet and mobile devices. below is my code for the nav as well as a link to the site.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.html" ></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle active" aria-current="page" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Category
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="#">Mens</a></li>
<li><a class="dropdown-item" href="#">Jackets</a></li>
<li><a class="dropdown-item" href="#">Outer Wear</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" aria-current="page" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Collection
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="#">Winter</a></li>
<li><a class="dropdown-item" href="#">Spring</a></li>
<li><a class="dropdown-item" href="#">Summer</a></li>
<li><a class="dropdown-item" href="#">Fall</a></li>
</ul>
</li>
</li>
</ul>
<span class="navbar">
<i> <a type="button" class="btn fab fa-gratipay"href="favorites.html" target="_self"> <span class="favoritesCount"></span> </a></i>
<i> <a type="button" class="btn fas fa-shopping-cart Cart" href="cart.html" target="_self" ><span class="navbarCart" data-totalitems="0"></span></a></i>
</span>
</div>
</div>
</nav>
</section>
here is the CSS
/* nav container */
.container-fluid{
border-bottom: black solid 3px ;
width: 100%;
height: 50px;
}
.container-fluid a{
margin-left: 3%;
}
/* .navbar-brand
{
position: relative;
background: url(../images/logo.png);
width: 170px;
left: 15px;
max-height: 70px;
} */
.navbar-brand
{
position: relative;
background: url(../images/fakeLogo.png);
width: 100px;
height: 40px;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
}
.navbar span{
padding: 0 8px;
margin-right: 3%;
}
.Cart{
width: 100px;
font-size: 40px;
color: #000;
padding: 0;
position: relative;
}
https://connorlewis128.github.io/ShoppingPage/Dist/product.html
please let me know if any more code or information is needed.
If I am understanding you correctly...
Do you want your favourites and cart icons to not spread across the page?
You need to remove justify-content: space-between; from span.navbar

Bootstrap 4 - Responsive + Centred & Word Wrapped navbar-brand

I have been trying to make a bootstrap 4 navbar that has a centered navbar-brand (text) with the emblem on the far left and links on the right I have managed to do this with it being almost correct however I have a large brand name therefore I need it to text wrap when I go below a certain width however instead of it text wrapping it pushes the other elements out of the way before wrapping how can I fix this?
Current code:
.embelem{
height:40px;
width:40px;
}
#media (min-width: 768px) {
.abs-center-x {
position: absolute;
left: 50%;
transform: translateX(-50%);
text-align:center;
}
#title {
padding: 13px
}
}
<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>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar sticky-top navbar-expand-lg navbar-light bg-light">
<picture class="embelem">
<source srcset="https://lucas-testing.000webhostapp.com/images/embelem.webp" class="embelem" alt="Embelem" type="image/webp">
<source srcset="https://lucas-testing.000webhostapp.com/images/embelem.png" class="embelem" alt="Embelem" type="image/png">
<img src="https://lucas-testing.000webhostapp.com/images/embelem.webp" class="embelem" alt="Embelem" type="image/webp">
</picture>
<a id="title" class="sticky-top navbar-brand abs-center-x text-wrap" style="color: #818181;" href="./">The City of Truro Mariners</a>
<button class="navbar-toggler" 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 ml-auto">
<li class="nav-item">
<a class="nav-link" href="./index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./members page">Members page</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./contact us">Contact us</a>
</li>
<li class="nav-item dropdown" style="cursor:pointer">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Extra's</a>
<div id="dropdownSlider" class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="./release/index">App Download</a>
<a class="dropdown-item" href="./links">Links</a>
<a class="dropdown-item" href="./dates for the diary">Dates for the diary</a>
</div>
</li>
</ul>
</div>
</nav>
Applying these styles will wrap the text without truncating it:
#media (max-width: 768px){
.navbar-brand{
flex: 1 0 100px;
text-align: center;
}
}
.embelem{
height:40px;
width:40px;
}
#media (max-width: 768px){
.navbar-brand{
flex: 1 0 100px;
text-align: center;
}
}
#media (min-width: 768px) {
.abs-center-x {
position: absolute;
left: 50%;
transform: translateX(-50%);
text-align:center;
}
#title {
padding: 13px
}
}
<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>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar sticky-top navbar-expand-lg navbar-light bg-light">
<picture class="embelem">
<source srcset="https://lucas-testing.000webhostapp.com/images/embelem.webp" class="embelem" alt="Embelem" type="image/webp">
<source srcset="https://lucas-testing.000webhostapp.com/images/embelem.png" class="embelem" alt="Embelem" type="image/png">
<img src="https://lucas-testing.000webhostapp.com/images/embelem.webp" class="embelem" alt="Embelem" type="image/webp">
</picture>
<a id="title" class="sticky-top navbar-brand abs-center-x text-wrap" style="color: #818181;" href="./">The City of Truro Mariners</a>
<button class="navbar-toggler" 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 ml-auto">
<li class="nav-item">
<a class="nav-link" href="./index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./members page">Members page</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./contact us">Contact us</a>
</li>
<li class="nav-item dropdown" style="cursor:pointer">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Extra's</a>
<div id="dropdownSlider" class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="./release/index">App Download</a>
<a class="dropdown-item" href="./links">Links</a>
<a class="dropdown-item" href="./dates for the diary">Dates for the diary</a>
</div>
</li>
</ul>
</div>
</nav>
replace you navbar-brand css to this code below. and remove .text-wrap class to make it work
.embelem{
height:40px;
width:40px;
}
.navbar-brand {
padding-top: .3125rem;
padding-bottom: .3125rem;
margin-right: 1rem;
font-size: 1.25rem;
line-height: inherit;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap !important;
display: block;
width: 50%;
min-width: 1px;
}
#media (min-width: 768px) {
.abs-center-x {
position: absolute;
left: 50%;
transform: translateX(-50%);
text-align:center;
}
#title {
padding: 13px
}
}
<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>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar sticky-top navbar-expand-lg navbar-light bg-light">
<picture class="embelem">
<source srcset="https://lucas-testing.000webhostapp.com/images/embelem.webp" class="embelem" alt="Embelem" type="image/webp">
<source srcset="https://lucas-testing.000webhostapp.com/images/embelem.png" class="embelem" alt="Embelem" type="image/png">
<img src="https://lucas-testing.000webhostapp.com/images/embelem.webp" class="embelem" alt="Embelem" type="image/webp">
</picture>
<a id="title" class="sticky-top navbar-brand abs-center-x" style="color: #818181;" href="./">The City of Truro Mariners</a>
<button class="navbar-toggler" 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 ml-auto">
<li class="nav-item">
<a class="nav-link" href="./index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./members page">Members page</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./contact us">Contact us</a>
</li>
<li class="nav-item dropdown" style="cursor:pointer">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Extra's</a>
<div id="dropdownSlider" class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="./release/index">App Download</a>
<a class="dropdown-item" href="./links">Links</a>
<a class="dropdown-item" href="./dates for the diary">Dates for the diary</a>
</div>
</li>
</ul>
</div>
</nav>

Bootstrap: when navbar collapsed branding overlapping other objects

When the navbar collapses into the burger menu, the branding overlaps with the navigation links - how do I separate them to avoid this happening? Ideally I'd like the branding to appear at the top.
The navbar structure is correct and working as expected when not collapsed, with all items positioned correctly, the problem only occurs when the menu collapses.
JSFiddle: https://jsfiddle.net/PeterLawson/Lkv8gj9a/2/
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!---Style Sheets-->
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<!---Website Title-->
<title>Notepad</title>
</head>
<body>
<!---Main Content-->
<!---Navigation Bar-->
<nav class="navbar nav-fill navbar-expand-lg navbar-light bg-light ">
<div class="container">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarMenu">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarMenu">
<!---Search Bar-->
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
<!---Notepad Branding-->
<ul class="nav navbar-nav navbar-center">
<li><a class="navbar-brand" href="#"><img src="images\notepad-logo2.png" alt="Notepad Logo"
style="width:150px;"></a></li>
</ul>
<!---Navigation Links-->
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Discover Notepads</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarProductDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Catalogue
</a>
<div class="dropdown-menu" aria-labelledby="navbarProductDropdown">
<a class="dropdown-item" href="#">Furniture</a>
<a class="dropdown-item" href="#">Lighting</a>
<a class="dropdown-item" href="#">Decor</a>
</div>
</li>
<!---User Profile-->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarAvatarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<img src="images\man.png" class="avatar">
</a>
<div class="dropdown-menu" aria-labelledby="navbarAvatarDropdown">
<a class="dropdown-item" href="#">Profile</a>
<a class="dropdown-item" href="#">My Notepads</a>
<a class="dropdown-item" href="#">Create New Notepad</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Sign Out</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
<!---Bootstrap JavaScript and jQuery-->
<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.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<!---Firebase SDK-->
<script src="https://www.gstatic.com/firebasejs/6.3.5/firebase-app.js"></script>
</body>
</html>
CSS:
.navbar-nav.navbar-center {
position: absolute;
left: 50%;
transform: translatex(-50%);
}
.navbar {
margin-left: 10px;
margin-right: 10px;
}
.main-logo{
width: 150px;
height: 50px;
}
.navbar-nav li a {
line-height: 50px;
}
.dropdown-menu > li > a {
height: 50px;
}
.avatar {
width: 48px;
height: 48px;
border-radius: 50%;
box-shadow:
inset 0 0 0 2px rgba(255,255,255,0.6),
0 1px 1px rgba(0,0,0,0.1);
background-color: transparent !important;
z-index: 999;
}
.avatar img {
border-radius: inherit;
width: inherit;
height: inherit;
display: block;
position: relative;
z-index: 998;
}
Simplest solution will be to take the brandImage out of the navigation - that'll help you achieve what you want; your styles.css file wasn't referred to completely, so i inserted a different logo - based on your logo, you would have to tune the padding etc.
Working snippet below:
.navbar-nav.navbar-center {
position: absolute;
left: 50%;
transform: translatex(-50%);
}
.navbar {
margin-left: 10px;
margin-right: 10px;
}
.main-logo {
width: 150px;
height: 50px;
}
.navbar-nav li a {
line-height: 50px;
}
.dropdown-menu>li>a {
height: 50px;
}
.avatar {
width: 48px;
height: 48px;
border-radius: 50%;
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6), 0 1px 1px rgba(0, 0, 0, 0.1);
background-color: transparent !important;
z-index: 999;
}
.avatar img {
border-radius: inherit;
width: inherit;
height: inherit;
display: block;
position: relative;
z-index: 998;
}
.navBarBrand {
list-style: none;
position: absolute;
left: calc(50% - 21px);
padding: 0;
z-index: 1;
}
#media screen AND (min-width:991px) {
.navBarBrand {
padding: 12px 0px;
}
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<!---Website Title-->
<!---Main Content-->
<ul class="navBarBrand">
<li>
<a class="=" href="#"><img src="https://www.akberiqbal.com/apple-touch-icon-57x57.png" alt="Notepad Logo"></a>
</li>
</ul>
<!---Navigation Bar-->
<nav class="navbar nav-fill navbar-expand-lg navbar-light bg-light ">
<div class="container">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarMenu">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarMenu">
<!---Search Bar-->
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
<!---Notepad Branding-->
<!---Navigation Links-->
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Discover Notepads</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarProductDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Catalogue
</a>
<div class="dropdown-menu" aria-labelledby="navbarProductDropdown">
<a class="dropdown-item" href="#">Furniture</a>
<a class="dropdown-item" href="#">Lighting</a>
<a class="dropdown-item" href="#">Decor</a>
</div>
</li>
<!---User Profile-->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarAvatarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src="images\man.png" class="avatar">
</a>
<div class="dropdown-menu" aria-labelledby="navbarAvatarDropdown">
<a class="dropdown-item" href="#">Profile</a>
<a class="dropdown-item" href="#">My Notepads</a>
<a class="dropdown-item" href="#">Create New Notepad</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Sign Out</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
<!---Bootstrap JavaScript and jQuery-->
<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.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!---Firebase SDK-->
<script src="https://www.gstatic.com/firebasejs/6.3.5/firebase-app.js"></script>

How to make the height of dropdown menu same as the height of submenu in bootstrap 4

I am making a navbar with multi level drop down menu. I want to make the height of drop-down menu same as the height of sub-menu.
Like This:
When the sub-menu is hidden, the drop-down menu will return the original size.
Like This:
Here is my code
.dropdown-submenu a::after {
transform: rotate(-90deg);
right: 3px;
top: 40%;
}
.dropdown-submenu:hover .dropdown-menu,
.dropdown-submenu:focus .dropdown-menu {
display: block;
margin-top: -1px;
margin-left: -1px;
top: 0px;
left: 100%;
min-height: 100%;
}
.dropdown-menu {
min-height: 200%;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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-sm navbar-light ">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<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>
<ul class="dropdown-menu " aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="#">Action</a></li>
<li class="dropdown-submenu"><a class="dropdown-item dropdown-toggle" data-toggle="dropdown" href="#">Something else here</a>
<div class="dropdown-menu top">
<a class="dropdown-item" href="#">A</a>
<a class="dropdown-item" href="#">b</a>
<a class="dropdown-item" href="#">b</a>
<a class="dropdown-item" href="#">b</a>
<a class="dropdown-item" href="#">b</a> <a class="dropdown-item" href="#">b</a> <a class="dropdown-item" href="#">b</a>
</div>
</li>
</ul>
</li>
</ul>
</nav>
How can i do this?
Is this what you wanted? I added a class .add-to-ul and a class .add-to-dropdown-div at, well the name says it. And gave it some styles.
Also I added an ID to the nav so I can style the bootstrap elements easier.
.dropdown-submenu a::after {
transform: rotate(-90deg);
right: 3px;
top: 40%;
}
.dropdown-submenu:hover .dropdown-menu,
.dropdown-submenu:focus .dropdown-menu {
display: block;
margin-top: -1px;
margin-left: -1px;
top: 0px;
left: 100%;
min-height: 100%;
}
.dropdown-menu {
min-height: 200%;
}
#bootstrap-edits .add-to-ul{
position: relative;
width: 100%;
top: 0;
}
#bootstrap-edits .add-to-dropdown-div{
min-height: 100%;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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-sm navbar-light " id="bootstrap-edits">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<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>
<ul class="dropdown-menu add-to-ul" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="#">Action</a></li>
<li class="dropdown-submenu"><a class="dropdown-item dropdown-toggle" data-toggle="dropdown" href="#">Something else here</a>
<div class="dropdown-menu top add-to-dropdown-div">
<a class="dropdown-item" href="#">A</a>
<a class="dropdown-item" href="#">b</a>
<a class="dropdown-item" href="#">b</a>
<a class="dropdown-item" href="#">b</a>
<a class="dropdown-item" href="#">b</a> <a class="dropdown-item" href="#">b</a> <a class="dropdown-item" href="#">b</a>
</div>
</li>
</ul>
</li>
</ul>
</nav>

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>