Since some time I have been working on a chat room layout and the main concept of my website (Which i'll be showing) is that I have a fixed navbar and a fixed bottom footer (Bootstrap 4). So between them I added a grid system with 3 columns (3 + 6 + 3) Now I want the grid system to be the height so it covers the whole area between the navbar and the footer. But the problem is when I give them the height of 100% a scrollbar comes up and makes it a full page grid.
My Code :
.dropdown-toggle::after {
content: none;
}
body {
margin: 0;
padding: 0;
}
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand navbar-dark" style="background-color:#3A5070">
<a class="navbar-brand" href="#">LOGO</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" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<img src="https://image.flaticon.com/icons/svg/1156/1156949.svg" width="25" style="margin-top:10px;margin-right:15px;" />
</li>
<li class="nav-item">
<img src="https://image.flaticon.com/icons/svg/813/813020.svg" width="25" style="margin-top:10px;margin-right:15px;" />
</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">
<img src="libs/images/icon.png" width="35" />
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown" style="margin-top:7px;border-radius:0px;width:110%;">
<a class="dropdown-item" href="#">Edit Profile</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Logout</a>
</div>
</li>
</ul>
</div>
</nav>
<div class="row no-gutter" style="height:100%">
<div class="col-3" style="background: orange;">col-3</div>
<div class="col-6" style="background:black;">col-6</div>
<div class="col-3" style="background: orange;">col-3</div>
</div>
<nav class="navbar fixed-bottom navbar-light " style="background-color:#3A5070">
<a class="navbar-brand" href="#"></a>
</nav>
Use calc() to calculate the height of a element:
<style>
.full_height {
height: calc(100vh - 82px);
overflow: auto;
}
</style>
.full_height {
height: calc(100vh - 82px);
overflow: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand navbar-dark" style="background-color:#3A5070">
<a class="navbar-brand" href="#">LOGO</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" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<img src="https://image.flaticon.com/icons/svg/1156/1156949.svg" width="25"
style="margin-top:10px;margin-right:15px;" />
</li>
<li class="nav-item">
<img src="https://image.flaticon.com/icons/svg/813/813020.svg" width="25"
style="margin-top:10px;margin-right:15px;" />
</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">
<img src="libs/images/icon.png" width="35" />
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"
style="margin-top:7px;border-radius:0px;width:110%;">
<a class="dropdown-item" href="#">Edit Profile</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Logout</a>
</div>
</li>
</ul>
</div>
</nav>
<div class="container-fluid full_height">
<div class="row no-gutter text-center" style="height:100%">
<div class="col-3" style="background: orange;">col-3</div>
<div class="col-6" style="background:black;color:white;">col-6</div>
<div class="col-3" style="background: orange;">col-3</div>
</div>
</div>
<nav class="navbar fixed-bottom navbar-light " style="background-color:#3A5070">
<a class="navbar-brand" href="#"></a>
</nav>
codepen link
Use CSS flex. Giving height 100% will take all the height inherits from its parent. here you are trying to set the content height to 100%. So it takes all height available and there is no space for header and footer. If you try to include header and footer with the content then the page gets overflow. So the scroll comes.
body{
margin:0;
padding:0;
display:flex;
height: 100%;
position: absolute;
width: 100%;
flex-direction:column;
}
.row.no-gutter {
flex: 1;
overflow: auto;
margin: 0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand navbar-dark" style="background-color:#3A5070">
<a class="navbar-brand" href="#">LOGO</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" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<img src="https://image.flaticon.com/icons/svg/1156/1156949.svg" width="25" style="margin-top:10px;margin-right:15px;"/>
</li>
<li class="nav-item">
<img src="https://image.flaticon.com/icons/svg/813/813020.svg" width="25" style="margin-top:10px;margin-right:15px;"/>
</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">
<img src="libs/images/icon.png" width="35" />
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown" style="margin-top:7px;border-radius:0px;width:110%;">
<a class="dropdown-item" href="#">Edit Profile</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Logout</a>
</div>
</li>
</ul>
</div>
</nav>
<div class="row no-gutter" >
<div class="col-3" style="background: orange;">col-3</div>
<div class="col-6" style="background:black;">col-6</div>
<div class="col-3" style="background: orange;">col-3</div>
</div>
<nav class="navbar fixed-bottom navbar-light " style="background-color:#3A5070">
<a class="navbar-brand" href="#"></a>
</nav>
Related
I'm working on a bootstrap navbar with the bootstrap 4 version and I have a problem aligning the navbar item on the left because I have some items on the right and I want to make a profile avatar pulled to the left I tried to use [Pull-left] and [ml-auto] but there it doesn't work and so any help?
navbar code:-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<nav class="navbar navbar-expand-md navbar-dark bg-dark shadow p-3 mb-5" style="direction: rtl; margin:0;">
<div class="container-fluid">
<a class="navbar-brand" href="#"><img src="styles/images/svgtopng.png" alt="" width="65" height="" class="d-inline-block align-top mr-auto"><span style="font-family: hana;">المتجر المتعدد</span></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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">
<div class="navbar-inner" style="float:right">
<ul class="navbar-nav mr-auto">
<li class="nav-item" style="font-family: cocon-next-arabic; font-size:26px;">
<a class="nav-link active pull-right" aria-current="page" style="direction: rtl;" href="index.php">الرئيسية<img src="styles/images/home.png" alt="" width="66" height="47" class="d-inline-block align-top mr-auto"></a>
</li>
<li class="nav-item" style="font-family: cocon-next-arabic; font-size:26px;">
<a class="nav-link active pull-right" aria-current="page" style="direction: rtl;" href="store.php">المتجر<img src="styles/images/cart.png" alt="" width="66" height="47" class="d-inline-block align-top mr-auto"></a>
</li>
<li class="nav-item" style="font-family: cocon-next-arabic; font-size:26px;">
<a class="nav-link active pull-left" aria-current="page" style="direction: rtl;" href="store.php">Pull Left<img src="styles/images/cart.png" alt="" width="66" height="47" class="d-inline-block align-top mr-auto"></a>
</li>
</ul>
</div>
</ul>
</div>
</div>
</nav>
I think this is what you need.
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark" style="direction:rtl">
<a class="navbar-brand" 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" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto" style="direction:ltr; padding-right:40px">
<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>
<ul class="mr-auto navbar-nav">
<li class="nav-item">
Avator
<img style="display:inline-block; width:40px; height:40px; border-radius:50px" src="https://png.pngtree.com/png-vector/20190223/ourmid/pngtree-vector-avatar-icon-png-image_695765.jpg" />
</li>
</ul>
</div>
</nav>
<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>
</body>
</html>
because you add inline css to nav element and change the direction to right remove it
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<nav class="navbar navbar-expand-md navbar-dark bg-dark shadow p-3 mb-5" style="margin:0;">
<div class="container-fluid">
<a class="navbar-brand" href="#"><img src="styles/images/svgtopng.png" alt="" width="65" height="" class="d-inline-block align-top mr-auto"><span style="font-family: hana;">المتجر المتعدد</span></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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">
<div class="navbar-inner" style="float:right">
<ul class="navbar-nav mr-auto">
<li class="nav-item" style="font-family: cocon-next-arabic; font-size:26px;">
<a class="nav-link active pull-right" aria-current="page" style="direction: rtl;" href="index.php">الرئيسية<img src="styles/images/home.png" alt="" width="66" height="47" class="d-inline-block align-top mr-auto"></a>
</li>
<li class="nav-item" style="font-family: cocon-next-arabic; font-size:26px;">
<a class="nav-link active pull-right" aria-current="page" style="direction: rtl;" href="store.php">المتجر<img src="styles/images/cart.png" alt="" width="66" height="47" class="d-inline-block align-top mr-auto"></a>
</li>
<li class="nav-item" style="font-family: cocon-next-arabic; font-size:26px;">
<a class="nav-link active pull-left" aria-current="page" style="direction: rtl;" href="store.php">Pull Left<img src="styles/images/cart.png" alt="" width="66" height="47" class="d-inline-block align-top mr-auto"></a>
</li>
</ul>
</div>
</ul>
</div>
</div>
</nav>
I have created two navigation bars, where the one below is included in the dropdown toggle icon when screen becomes small. On the first navigation bar, I have two items pushed to the far right. When I resize the screen, I can see the hamburger icon; however, these items become stacked on each other. I know that if I use navbar-expand the items will be displayed properly, but then the hamburger icon won't be shown.
This is my code:
<script src="https://code.jquery.com/jquery-3.5.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.5.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<!-- First navigation bar -->
<div class="container-fluid" style="margin-top: 0px;">
<nav class="navbar navbar-light navbar-expand-sm bg-white">
<div id="burger">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation" style="border: none; background: none; outline:none;">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<a class="navbar-brand" href="#"> <img src="assets/logo/logo.PNG" width="160" height="60" class="d-inline-block align-top" alt=""> </a>
<div class="navbar-nav ml-auto"> <!-- the items on the right -->
<div class="dropdown item" style="margin-top: 12px; margin-right: 10px;">
<button class="no-style dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="notification_button">
<span class="icon icofont-notification text-secondary"></span>
<div>
<span class="badge badge-danger badge-sm">6</span>
</div>
</button>
</div>
<div class="dropdown item">
<button class="no-style dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-offset="0, 10" style="border: none; background: none; outline:none;">
<span class="d-flex align-items-center">
<img src="/assets/content/user.jpg" style="border-radius: 500px!important;" alt="" width="40" height="40" class="mr-1"> <i class="icofont-simple-down"></i>
</span>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" x-placement="bottom-end">
<span class="icon icofont-ui-home"></span> Edit account
<span class="icon icofont-ui-user"></span> User profile
<span class="icon icofont-ui-calendar"></span> Calendar
<span class="icon icofont-ui-settings"></span> Settings
<span class="icon icofont-logout"></span> Log Out
</div>
</div>
</div>
</nav>
</div>
<!-- Second navigation bar -->
<div class="container-fluid" style="margin-top: -10px;">
<nav class="navbar navbar-light navbar-expand-sm">
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link" href="/link-1">link</a>
<a class="nav-item nav-link" href="/link-2">link</a>
<a class="nav-item nav-link" href="/link-3">link</a>
</div>
</div>
</nav>
</div>
How can I display the hamburger and the two items on the right without having them stacked on each other?
They are stacked on each other because their container has the navbar-nav class apllied, which contains the property "flex-direction:column", you should apply "flex-direction:row" instead in the css, or the class "flex-row" in the html:
<div class="navbar-nav ml-auto flex-row">
</div>
Your problem is that the style
.navbar-expand-sm .navbar-nav {
-ms-flex-direction: row;
flex-direction: row;
}
in _navbar.scss is limited to a min-width of 576px using a media query.
In order to achieve your goal you can apply the style manually resulting in your items not get stacked anymore, like this:
<script src="https://code.jquery.com/jquery-3.5.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.5.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<style>
#right-navbar {
-ms-flex-direction: row;
flex-direction: row;
}
</style>
<!-- First navigation bar -->
<div class="container-fluid" style="margin-top: 0px;">
<nav class="navbar navbar-light navbar-expand-sm bg-white">
<div id="burger">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation" style="border: none; background: none; outline:none;">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<a class="navbar-brand" href="#"> <img src="assets/logo/logo.PNG" width="160" height="60" class="d-inline-block align-top" alt=""> </a>
<div id="right-navbar" class="navbar-nav ml-auto"> <!-- the items on the right -->
<div class="dropdown item" style="margin-top: 12px; margin-right: 10px;">
<button class="no-style dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="notification_button">
<span class="icon icofont-notification text-secondary"></span>
<div>
<span class="badge badge-danger badge-sm">6</span>
</div>
</button>
</div>
<div class="dropdown item">
<button class="no-style dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-offset="0, 10" style="border: none; background: none; outline:none;">
<span class="d-flex align-items-center">
<img src="/assets/content/user.jpg" style="border-radius: 500px!important;" alt="" width="40" height="40" class="mr-1"> <i class="icofont-simple-down"></i>
</span>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" x-placement="bottom-end">
<span class="icon icofont-ui-home"></span> Edit account
<span class="icon icofont-ui-user"></span> User profile
<span class="icon icofont-ui-calendar"></span> Calendar
<span class="icon icofont-ui-settings"></span> Settings
<span class="icon icofont-logout"></span> Log Out
</div>
</div>
</div>
</nav>
</div>
<!-- Second navigation bar -->
<div class="container-fluid" style="margin-top: -10px;">
<nav class="navbar navbar-light navbar-expand-sm">
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link" href="/link-1">link</a>
<a class="nav-item nav-link" href="/link-2">link</a>
<a class="nav-item nav-link" href="/link-3">link</a>
</div>
</div>
</nav>
</div>
The result looks like the following:
Good luck!
This question already has answers here:
Bootstrap NavBar with left, center or right aligned items
(14 answers)
Centering brand logo in Bootstrap Navbar
(7 answers)
Closed 2 years ago.
I'm trying to place a logo on my navbar, right in the center. The navbar automatically stretches to be the same size as the image which I don't want. How do I put a logo on my navbar that overlaps/doesn't stretch the navbar?
<nav class="navbar navbar-expand-lg navbar-light bg-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 mx-auto ">
<li class="nav-item active ">
<a class="nav-link " href="#">Home <span class="sr-only">(current)</span></a>
</li>
<div class="navbar-brand">
<img src = "test-logo.png" height="250" width="250" alt="test logo">
</div>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
</nav>
Hello here is the example code for your problem..
.navbar-brand {margin: 0 30px;padding: 0;}
.navbar-brand img {max-height: 68px;}
nav.navbar .navbar-nav li a {
padding: 0 20px;
line-height: 68px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<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="navbar-brand d-block d-md-none">
<img src="https://www.jing.fm/clipimg/full/135-1359070_test-logos-full-logo-with-text-and-simple.png" width="60px" alt="logo" />
</div>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mx-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="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link " href="#">Services</a>
</li>
<div class="navbar-brand d-none d-md-block">
<img src="https://www.jing.fm/clipimg/full/135-1359070_test-logos-full-logo-with-text-and-simple.png" alt="logo" />
</div>
<li class="nav-item">
<a class="nav-link" href="#">Blog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">career</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.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>
Below is the code for my Navbar:
<nav class="navbar navbar-expand-lg navbar-dark custom-bg-primary text-white fixed-top mb-3 py-2">
<div class="container">
<a class="navbar-brand" href="{% url 'job-list' %}"><img src="{% static 'jobs/images/sirf-sarkari-naukri.png' %}" alt="Sirf Sarkari Naukri" height="25%" width="25%"></a>
<!-- <a class="navbar-brand" href="{% url 'job-list' %}">Sirf Sarkari Naukri</a> -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle py-0" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">SARKARI JOBS</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">BY COMPANY</a>
<hr />
<a class="dropdown-item" href="#">BY QUALIFICATION</a>
<a class="dropdown-item" href="#">BY PROFESSION</a>
<hr />
<a class="dropdown-item" href="#">BY STATE</a>
<a class="dropdown-item" href="#">BY TOP CITIES</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
After I added logo to my Navbar, on small screen the Navbar Toggler button is getting shifted to new line and overlapping on the search bar.
Could anyone please help me fix this issue, thanks in advance!
display:inline is causing this... use display:contents to resolve
nav {
background-color: #229a44;
}
a.navbar-brand {
display: contents;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous" />
<nav class="navbar navbar-expand-lg navbar-dark custom-bg-primary text-white fixed-top mb-3 py-2">
<div class="container">
<a class="navbar-brand" href="{% url 'job-list' %}">
<img src="https://i.stack.imgur.com/Jqd4Z.png" alt="Sirf Sarkari Naukri" height="25%" width="25%">
<!--
<img src="https://www.akberiqbal.com/favicon.ico" alt="Sirf Sarkari Naukri" height="25%" width="25%">
-->
</a>
<!-- <a class="navbar-brand" href="{% url 'job-list' %}">Sirf Sarkari Naukri</a> -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-thumbs-up"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle py-0" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">SARKARI JOBS</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">BY COMPANY</a>
<hr />
<a class="dropdown-item" href="#">BY QUALIFICATION</a>
<a class="dropdown-item" href="#">BY PROFESSION</a>
<hr />
<a class="dropdown-item" href="#">BY STATE</a>
<a class="dropdown-item" href="#">BY TOP CITIES</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
Having issues with the collapsing menu still. According to the way bootstrap is set up, when it collapses, it should go into a straight vertical nav instead of still stretching horizontal. It only seems to end up vertically correct when at the lowest screen size and even though only displays correctly on one of the menus. Thank you Gary for pointing out and helping fix the first issue with the buttons and ID's
first image is how it's supposed to look
Correct Display
My Display
Here's the Snippet of code I put up on codely
<nav class="navbar navbar-expand-xl navbar-light bg-dark" id="topbar">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAlt" aria-controls="navbarNavAlt" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAlt">
<ul class="nav nav-navbar">
<li class="nav-item nav-link">
<a href="tel:1-702-555-5555">
<img src="image/phone.svg" height="15px" alt="Telephone"> (702)555-5555
</a>
</li>
<li class="nav-item nav-link">
<a href="mailto:mail#mail.com">
<img src="image/email.svg" height="15px" alt="Email"> mail#mail.com
</a>
</li>
<li class="nav-item nav-link" href="#">Premier Face Punching</li>
<li class="nav-item nav-link">
<a href="https://www.linkedin.com/company/Stuffnthings/">
<img src="image/linkedin.png" height="15px">
</a>
<a href="https://www.facebook.com/stuffnthings">
<img src="image/facebook.png" height="15px">
</a>
<a href="https://www.twitter.com/stuffnthings">
<img src="image/twitter.png" height="15px">
</a>
</li>
<li>
<input class="form-control border-secondary py-2" type="search" value="search">
</li>
</ul>
</div>
</nav>
<nav class="navbar navbar-expand-md navbar-light bg-light sticky-top" id="mainnav">
<a class="navbar-brand" href="#">
<img src="image/VC-Logo.png" height="192px" alt="VC Logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse ml auto" id="navbarNavAltMarkup">
<div class="nav nav-pills">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Web Design</a>
<a class="nav-item nav-link" href="#">Graphic Design</a>
<a class="nav-item nav-link" href="#">About US</a>
<a class="nav-item nav-link" href="#">Contact US</a>
</div>
</div>
</nav>
Your target attribute for both the navbar is same. Just replace the target attribute and the button works for different nav bar. And the navbar seems to become vertical when the width of the browser is less.
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-xl navbar-light bg-dark" id="topbar">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAlt" aria-controls="navbarNavAlt" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAlt">
<ul class="nav-navbar">
<li class="nav-item nav-link">
<a href="tel:1-702-555-5555">
<img src="image/phone.svg" height="15px" alt="Telephone"> (702)555-5555
</a>
</li>
<li class="nav-item nav-link">
<a href="mailto:mail#mail.com">
<img src="image/email.svg" height="15px" alt="Email"> mail#mail.com
</a>
</li>
<li class="nav-item nav-link" href="#">Premier Face Punching</li>
<li class="nav-item nav-link">
<a href="https://www.linkedin.com/company/Stuffnthings/">
<img src="image/linkedin.png" height="15px">
</a>
<a href="https://www.facebook.com/stuffnthings">
<img src="image/facebook.png" height="15px">
</a>
<a href="https://www.twitter.com/stuffnthings">
<img src="image/twitter.png" height="15px">
</a>
</li>
<li>
<input class="form-control border-secondary py-2" type="search" value="search">
</li>
</ul>
</div>
</nav>
<nav class="navbar navbar-expand-md navbar-light bg-light sticky-top" id="mainnav">
<a class="navbar-brand" href="#">
<img src="image/VC-Logo.png" height="192px" alt="VC Logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse ml auto" id="navbarNavAltMarkup">
<div class="nav-pills">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Web Design</a>
<a class="nav-item nav-link" href="#">Graphic Design</a>
<a class="nav-item nav-link" href="#">About US</a>
<a class="nav-item nav-link" href="#">Contact US</a>
</div>
</div>
</nav>
</body>
</html>