Bootstrap 5 navbar nav-link items not working - navbar

I'm having trouble adding a bootstrap navbar to my site, links will only work if I place them inside of a dropdown... if I add a regular nav-item > nav-link to the navbar it appears as text on the live site. I've read a ton of docs and threads and I cannot figure this out... I'm not sure what I'm doing wrong, or what to look for at this point and I would really appreciate any feedback!
Here is my html:
<nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
<div class="container-fluid"><a class="navbar-brand" href="#">LOGO</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">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item"><a class="nav-link" href="#overview">Overview </a></li>
<li class="nav-item dropdown"><a id="navbarDropdown" class="nav-link dropdown-toggle" role="button" href="#" data-bs-toggle="dropdown" aria-expanded="false">Next Steps</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#next_steps">Personalized</a></li>
<li><a class="dropdown-item" href="#general_next_steps">General</a></li>
</ul>
</li>
<li class="nav-item dropdown"><a id="navbarDropdown" class="nav-link dropdown-toggle" role="button" href="#" data-bs-toggle="dropdown" aria-expanded="false">Resources </a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#resources">Tutorials</a></li>
<li><a class="dropdown-item" href="#contact">Contact Us</a></li>
</ul>
</li>
</ul>
<form class="d-flex"><button class="btn btn-outline-success" type="submit">Log In</button></form></div>
</div>
</nav>
The only CSS I've changed from the Bootstrap file is:
.navbar {
top: 0 !important;
left: 0 !important;
width: 100% !important;
z-index: 99 !important;
}
.container-fluid { max-width: 1440px !important; }

Related

href doesn't work on Drop Down with bootstrap 4 (SOLVED)

I made a drop-down menu with bootstrap 4 and also change it into hover. Everything works great, but I cannot link properly through the href.
When I click "PRODUCTS", it doesn't switch to third.html.
How can I fix it?
SOLUTION
Also, how to remove the original click action since I already have the hover one?
SOLUTION
Here's my HTML:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#"></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">
<a class="nav-link" href="./second.html">ABOUT</a>
</li>
<li class="nav-item dropdown">
<a
class="nav-link dropdown-toggle"
href="./third.html"
id="navbarDropdownMenuLink"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
PRODUCTS
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#ch1">A</a>
<a class="dropdown-item" href="#ch2">B</a>
<a class="dropdown-item" href="#ch3">C</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="./fourth.html">EQUIPMENT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./fifth.html">CONTACT</a>
</li>
</ul>
</div>
</nav>
CSS:
.dropdown:hover > .dropdown-menu {
display: block;
margin-top: 0;
}
Thanks!

Bootstrap navbar doesn't expand while using bottom bar

I'am learning how to use bootstrap, but I have a problem with reponsiveness.
When I have my content wide it looks like my navbar doesn't expand to the right:
Here is code of my navbar:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</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">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</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-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
Does anybody know how to fix it?
Can you put an id or a class and then select it in your css file. After that you can give
width: 100% or width: 100vw if these don't work u can use overflow-x: hidden;

Navbar Length resizing/fixing(whitespace) when window is minimized

When I minimize the window, there's white space at the right hand side of the nav-bar. I didn't use any css.
If anybody can help me with that. I have attached my html code here.
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">7AM Dashboard</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 mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Applications <span class="sr-only">(current)</span></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">
Domains
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" (click)="goToView('Channel')">Channel</a>
<a class="dropdown-item" (click)="goToView('Claims')">Claims</a>
<a class="dropdown-item" (click)="goToView('Member')">Member</a>
<a class="dropdown-item" (click)="goToView('Plan')">Plans</a>
<a class="dropdown-item" (click)="goToView('Provider')">Provider</a>
<!-- <div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>-->
</div>
</li>
<li>
<div class="d-inline-flex"><a class="nav-link " aria-haspopup="true" aria-expanded="false">
Date
</a>
<input type="date" (change)="changeDate()" [(ngModel)]="date"></div>
</li>
</ul>
</div>
</nav>
Try placing your nav inside a container-fluid, and add this to your css just in case:
html,body {
margin: 0;
padding: 0;
width: 100%;`enter code here`
height: 100%;
};
Btw, sometimes chrome does that! if you inspect/open your "yourFileName".html using Firefox it should behave properly.

Change font color of active dropdown menu

I am only a beginner in bootstrap and have a hard time figuring out how to change the css to my liking. I have a dropdown menu in my header and was able to change the colours. However, when the dropwdownmenu is selected, the font colour stays the same? How do I change this? I tried following:
.dropdown-toggle:active, .open .dropdown-toggle {
background:#ffffff !important;
color:#7dc623 !important;
}
but that doesn't change anything.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<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">
<a class="nav-link" href="#">Link 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 2</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
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Link 3</a>
<a class="dropdown-item" href="#">Link 4</a>
</div>
</li>
</ul>
</div>
</nav>
See the background is green, but the text is black, but should be white.
see screenshot
Removing .open from the code did the trick:
.dropdown-toggle:active, .dropdown-toggle {
background:#ffffff !important;
color:#7dc623 !important;
}
Applying your CSS properties on directly on a tag may cause certain issues, it would be advisable to use a span between the a tag for your text.
ie:
.navbar{
background-color: #FFFF99 !important;
}
.text_in_span{
color: #7dc623 !important;
}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#"><span class="text_in_span">Link 1</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><span class="text_in_span">Link 2</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">
<span class="text_in_span">Dropdown</span>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#"><span class="text_in_span">Link 3</span></a>
<a class="dropdown-item" href="#"><span class="text_in_span">Link 4</span></a>
</div>
</li>
</ul>
</div>
</nav>
I guess that should do the trick, cheers.

Bootstrap4 Navbar - Spacing Elements (Right, Center, Left)

I want to put my content in a navbar to 3 different 'columns'. All i want is logo on the left (checked) some nav-items on the center (checked) and the last element (Get The App) on the right and that's a problem.
Here's my code:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#"><img src="img/Logo.png"></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 mx-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Home
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Get The App</a>
</li>
</ul>
</div>
</nav>
and CSS:
.navbar-nav.mr-auto ul li a.nav-link {
justify-content: right;
display: flex;
flex-wrap: wrap; }
And this is my result:
I would appreciate any help, thanks ;)
Remove the mr-auto class from your last .navbar-nav.
That class applies margin-right: auto !important to your element, which makes it push against the right margin, just like mx-auto applies the same auto to both x sides (left and right).
See it working:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#"><img src="img/Logo.png"></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 mx-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Home
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Get The App</a>
</li>
</ul>
</div>
</nav>
you have to get rid of the margin-right: auto !important of the class .mr-auto.
Simply remove the class .mr-auto if you don't need it.
https://codepen.io/blackcityhenry/pen/bQYxyV