when I display the menu it goes to the right and scrolls the user profile. I need the menu to always be in the center and the profile always to the right.
I am using angular 12 and bootstrap 5.
Below I leave the code that I am using and some images of how it should look
Thanks!
link
stackblitz
<nav
class="navbar navbar-expand-lg navbar-dark bg-primary"
>
<div class="container-fluid">
<a class="navbar-brand"
><img src="../../../assets/Targaryen.ico"
/></a>
<button
class="navbar-toggler justify-content-center"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarTogglerbur"
aria-controls="navbarTogglerbur"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-center" id="navbarTogglerbur">
<ul class="navbar-nav justify-content-center mt-lg-0">
<li class="nav-item">
</li>
<li class="nav-item">
</li>
<li class="nav-item">
</li>
<li class="nav-item">
</li>
</ul>
</div>
<div class="dropdown">
<img
src="{{ info.photoURL }}"
/>
<ul
class="dropdown-menu dropdown-menu-end dropdown-menu-dark"
aria-labelledby="dropdownMenuButton1"
>
<li class="dropdown-item" >
</li>
<li class="dropdown-item" >
</li>
</ul>
</div>
</div>
</nav>
Simply switch the order of the navbar-nav and dropdown. Then use order-lg-last on the dropdown to keep it right on lg...
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container-fluid">
<a class="navbar-brand"><img src="//via.placeholder.com/30" /></a>
<button class="navbar-toggler justify-content-center" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerbur" aria-controls="navbarTogglerbur" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="dropdown order-lg-last">
<img src="//via.placeholder.com/30" />
<ul class="dropdown-menu dropdown-menu-end dropdown-menu-dark" aria-labelledby="dropdownMenuButton1">
<li class="dropdown-item">
<a href>Item</a>
</li>
<li class="dropdown-item">
<a href>Item</a>
</li>
</ul>
</div>
<div class="collapse navbar-collapse justify-content-center" id="navbarTogglerbur">
<ul class="navbar-nav justify-content-center mt-lg-0">
<li class="nav-item">
<a href class="nav-link">Item</a>
</li>
<li class="nav-item">
<a href class="nav-link">Item</a>
</li>
<li class="nav-item">
<a href class="nav-link">Item</a>
</li>
<li class="nav-item">
<a href class="nav-link">Item</a>
</li>
</ul>
</div>
</div>
</nav>
Codeply
Related
I tried to make an responsive bootstrap navigation bar but something isn't working. I even copy/paste the bootstrap navbar example and still the button doesn't show the menu when I click on it.
Can you help me solve it ?
<div class="header">
<nav class="navbar navbar-expand-lg cust">
<div class="container">
<a class="navbar-brand pSize" href="#">
<img src="log.png" class="d-inline-block imgBrandSize">
Logo
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
aria-label="Toggle navigation">
<i class="fa-solid fa-bars fa-lg"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Text</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Text</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Text</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
<div class="header">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand pSize" href="#">
<img src="log.png" class="d-inline-block imgBrandSize">
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 ms-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Text</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Text</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Text</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
this is working properly. This is Bootstrap-5. Please use data-bs-toggle and data-bs-target insted of data-toggle and data-target
Please Check This Code
I hed Two changes in your code.
This Is Bootstrap v4.0.0
<div class="header">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand pSize" href="#">
<img src="log.png" class="d-inline-block imgBrandSize">
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 ms-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Text</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Text</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Text</a>
</li>
</ul>
</div>
</div>
</nav>
enter image description here
I'm trying to create navbar at the top that sticks as one scrolls but is having difficulty trying to use bootstrap. My logo and the other text are not aligned.
HTML using bootstrap:
<!-- navbar -->
<nav class="navbar navbar-expand-lg navbar-light justify-content-end style="background-color: #e7a412;">
<div class="container-fluid">
<!-- Mos logo -->
<div><a class="navbar-brand ms-lg-3" href="#">
<img src="images/mos_logo.png" alt=""></div>
<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>-->
<i class="fas fa-bars"></i>
</button>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Mos Menu</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Mos Outlets</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Mos</a>
</li>
</ul>
<span class="navbar-text">
</span>
</div>
</div>
</nav>
But my text is not aligned to logo:
enter image description here
the code <a class="navbar-brand ms-lg-3" href="#"></a> under <li> tag take its space so logo and other text are not align. I guess you duplicated it incorrectly?
Also, I found that there are some missing syntax and closing tags with your code. Please take the below code for your reference.
Missing a " for <nav>'s class.
Missing closing </a> for the logo div.
A extra closing tag</button>.
<!-- navbar -->
<nav class="navbar navbar-expand-lg navbar-light justify-content-end" style="background-color: #e7a412">
<div class="container-fluid">
<!-- Mos logo -->
<div>
<a class="navbar-brand ms-lg-3" href="#"> <img src="images/mos_logo.png" alt="" /></a>
</div>
<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>-->
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Mos Menu</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Mos Outlets</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Mos</a>
</li>
</ul>
<span class="navbar-text"> </span>
</div>
</div>
</nav>
I started to edit my web and I added second logo in navbar. It looks okay on pc but when I try it on mobile, navbar is covering image.. I am using bootstrap 4 so I would like to know how that navbar is up the image and not in image... Thanks.
<nav id="menu" class="navbar fixed-top navbar-toggleable-sm bg-faded px-5 stin">
<button class="navbar-toggler navbar-toggler-right mr-3" 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="row d-flex align-items-end">
<div class="col-1 col-md-2 mr-1 mr-sm-0">
<a class="navbar-brand" href="#"> <img src="img/logo_barva.svg" height="90" class="pb-1"></a>´
</div>
</div>
<div class="collapse navbar-collapse prava pr-3" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto ">
<li class="nav-item active">
<a class="nav-link" href="#">DOMŮ<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="uklid.html">ÚKLIDOVÉ SLUŽBY</a>
</li>
<li class="nav-item">
<a class="nav-link" href="pece.html">DOMA PÉČE</a>
</li>
<!--<li class="nav-item dropdown">
SLUŽBY<span class="caret"></span>
<ul class="dropdown-menu col-xs-12" >
<li><a class="dropdown-item" href="uklid.html">Úklidové služby</a></li>
<li><a class="dropdown-item" href="pece.html">Domácí péče</a></li>
</ul>
</li>-->
<li class="nav-item">
<a class="nav-link" href="kariera.html">KARIÉRA</a>
</li>
<li class="nav-item">
<a class="nav-link" href="kontakt.html">KONTAKT</a>
</li>
</ul>
</div>
<div class="logo2">
<div class="col-5 col-md-2 mr-1 mr-sm-0">
<a class="navbar-brand pr-5" href="pece.html"> <img src="img/doma_pece.png" height="65" class="pb-1"></a>´
</div>
</div>
Well, I managed to do it.
If someone needed it:
#media screen and (max-width: 768px) {
body {
padding-top: 15.3rem;
padding-bottom: 0rem;
color: #5a5a5a;
}
}
the logo image fits nicely when the tab is full, but when i decreases the size of the tab, the logo doesnt stay inside the header
<header class="">
<nav class="navbar navbar-expand-lg">
<div class="container">
<a class="navbar-brand" href="index.html"
><img
src="assets/images/logoo.png"
alt="logo"
style="max-width:30%;height;"
/></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 active">
<a class="nav-link" href="index.html"
>Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="products.html">Our Products</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact Us</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
This question already has answers here:
Bootstrap change navbar color
(8 answers)
Change navbar color in Twitter Bootstrap
(12 answers)
Closed 3 years ago.
I've tried to use one of the recommended bootstrap 4 navbar styles. I pasted the code inside my project and all worked well. The only problem is that I've changed the background color from dark to white. Because of that text inside the navbar went invisible. I was trying many ways on how to change the text color to black so you can see the text but it didn't work and I can't figure out how do I change the color of the text from white to black.
I've tried adding the text-black class inside one of the navbar classes which didn't work as well.
Thanks for any help.
<!-- Navigation -->
<section id="navigation">
<nav class="navbar navbar-expand-lg navbar-dark bg-white static-top text-black">
<div class="container">
<a class="navbar-brand" href="#">
<img src="images/logo_5_150x60.png" alt="">
</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 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>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
</section>
The navbar-dark class on your <nav> element is the one setting the text color.
Change the navbar-dark to navbar-light when using light background colors.
Documentation: https://getbootstrap.com/docs/4.3/components/navbar/#color-schemes
<!-- Navigation -->
<section id="navigation">
<nav class="navbar navbar-expand-lg navbar-light bg-white static-top text-black">
<div class="container">
<a class="navbar-brand" href="#">
<img src="images/logo_5_150x60.png" alt="">
</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 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>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
</section>
Just add some css to #navigation * and set the color using color.
#navigation * {
color: red;
}
<!-- Navigation -->
<section id="navigation">
<nav class="navbar navbar-expand-lg navbar-dark bg-white static-top text-black">
<div class="container">
<a class="navbar-brand" href="#">
<img src="images/logo_5_150x60.png" alt="">
</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 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>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
</section>
Hope this helps