Bootstrap 5 hamburger menu won't remove show class - html

So I can open the menu just fine with the nav button, but when it opens I cannot close it with the button. I added some JS to allow the user to close the menu whenever clicking outside of the menu or on the links and that works...but for some reason, you still can't close the menu when clicking the button itself. I also noticed the button seems to work on my native desktop, but the website I'm developing is on Shopify's platform...so not sure if Shopify is getting in the way or what.
Here is how the nav looks in index.html:
<header>
<nav class="navbar fixed-top navbar-light navbar-expand-lg">
<div class="container-fluid">
<a class="navbar-brand w-25 m-0" href="#">
<img class="img-fluid" src="{{ 'image.png' | file_img_url: 'master' }}" alt="logo" />
</a>
<button class="navbar-toggler me-5" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="d-flex nav navbar-nav">
<li class="nav-item mx-auto">
<a class="nav-link text-uppercase fw-bold" href="#results">Results</a>
</li>
<li class="nav-item mx-auto">
<a class="nav-link text-uppercase fw-bold" href="#testimonies">Testimonials</a>
</li>
<li class="nav-item mx-auto">
<a class="nav-link text-uppercase fw-bold" href="#howItWorks">How it works</a>
</li>
<!-- Currently hidding section on mobile (TEMPORARY ONLY) -->
<li class="nav-item mx-auto d-none d-lg-block">
<a class="nav-link text-uppercase fw-bold" href="#team">Our Team</a>
</li>
<a class="btn mx-auto contact-btn text-uppercase px-4" role="button" href="#Contact">contact us</a>
</ul>
</div>
</div>
</nav>
</header>

Related

There are extra indents in the navbar in bootstrap 5, how to remove them?

There was a problem with extra padding in the navbar after the site icon. Initially, the idea was to place links that are located to the left of the icon closer to the left edge using me-3, but then the icon of the site is shifted to the right, which I basically don’t need.Therefore, I have a question. Is it possible to make the same indents from the site icon and links without shifting this icon from the center or how to remove the indent between the icon and links on the right side of the navbar.
<nav class="navbar navbar-expand-lg navbar-dark fixed-top" id="scroll">
<div class="container-fluid">
<div class="collapse navbar-collapse order-1 order-lg-0 dual-collapse2" id="navbarNavAltMarkup">
<ul class="navbar-nav ms-auto">
<li class="nav-item mx-auto">
<a class="nav-link" aria-current="page" href="#articles">기사들</a>
</li>
<li class="nav-item mx-auto">
<a class="nav-link" aria-current="page" href="#mission">우리의 임무</a>
</li>
</ul>
</div>
<a class="navbar-brand order-0" href="#">
<img src="img/marslogo.png" alt="" width="30" height="30">
</a>
<div>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="collapse navbar-collapse order-3 dual-collapse2" id="navbarNavAltMarkup"
>
<ul class="navbar-nav">
<li class="nav-item mx-auto">
<a class="nav-link" aria-current="page" href="#">사진들</a>
</li>
<li class="nav-item mx-auto">
<a class="nav-link" aria-current="page" href="#">문의하기</a>
</li>
</ul>
</div>
</div>
</nav>

Navbar is overlapping my content. bootstrap 4

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;
}
}

how to align navbar items to the right(not the brand)

its been so nice with stack overflow.I am currently in a bootcamp of Angela Yu.using bootstrap is fun but in the navbar section i am facing some issues.I cant move my nav item to the right.in the ul ,I am using a class ml-auto but its not running.For your better experience I m putting full code-
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="">tinDog</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01" >
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#"> contact</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"> Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"> download</a>
</li>
</ul>
</div>
</div>
i have put all other elements nicely!
can you guys give me a way or modify this code for my purpose?
The code above aligned it to the right for me when I tried it but I had to close out <nav>. In your code, you forgot to close it out with </nav>. Also, make sure you linked the bootstrap CDN properly by adding <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"> in the head of your html.I fixed the toggle button which wasn't working in smaller screens. Here is my code with the bootstrap style sheet included. Copy it and run it to see if it works for you.
<nav class="navbar navbar-expand-sm fixed-top navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand text-white" href="#" >tinDog</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
<ul class="navbar-nav ml-auto ">
<li class="nav-item">
<a class="nav-link text-light" href="#">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link text-light" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link text-light" href="#">Download</a>
</li>
</ul>
</div>
</div>
</nav>

bootstrap hamburger menu is collapsing with the nav items on mobile view

Whenever I click on the hamburger menu icon it collapses with the nav-items! what should I do to fix this issue now?
Navbar
<header>
<div class="container-fluid">
<div class="row">
<div class="col-12 col-sm-12">
<nav class="navbar navbar-toggleable-md fixed-top d-flex justify-content-center">
<a class="navbar-brand animated heartBeat delay-.5s" href="#home"><img class="img-fluid logo"
src="./Assets/Logos/LogoMakr_8A9Y2n.png" alt=""></a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
data-target="#vesco-menu" aria-controls="vesco-menu" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"><i class="fas fa-bars"
style="color:#fff; font-size: 30px; "></i>
</span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="vesco-menu">
<div class="navbar-nav nav nav-pills animated fadeInRight delay-1s">
<a class="nav-item nav-link active" href="#home">Home <span
class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#project">portfolios</a>
<a class="nav-item nav-link" href="#skills">skills</a>
<a class="nav-item nav-link" id="downlink" href="./Assets/RESUME.docx"
download>Resume</a>
<a class="nav-item nav-link" href="#testimonials">Testimonials</a>
<a class="nav-item nav-link" href="#contact">CONTACT ME</a>
</div>
</div>
</nav>
</div>
</div>
</div>
</header>
In my machine it works fine, I think the problem is in your custom CSS but I show one class that not exist in bootstrap 4 so I suggest you to replace it.
Replace navbar-toggleable-md with navbar-expand-md

Subtitle in nav bar + right aligned items

I've got a nav bar with a subtitle, the subtitle uses the technique from here:
Adding a subtitle to a Bootstrap Navbar
Unfortunately, when I added the sub-title, I lost the right-alignment on my nav bar - meaning I need some items to be right aligned, and they were, but not anymore since adding the sub-title.
Any idea how I could combine nav-bar sub-title with right-align?
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="d-flex flex-column">
<div class="d-sm-flex d-block flex-nowrap">
<div class="collapse navbar-collapse">
<ul id="navbar-section-list" class="navbar-nav mr-auto">
... a bunch of li/a here to represent left aligned items
</ul>
<ul class="navbar-nav">
<li class="nav-item dropdown-item-right">
<a id="refresh-button" class="nav-link" href="#">Refresh</a>
</li>
<li class="nav-item dropdown dropdown-item-right justify-content-end">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Account</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<span id="account-info-header" class="dropdown-item-text"></span>
<a class="dropdown-item">Settings</a>
<a class="dropdown-item" href="/auth/v1/logout">Log out</a>
</div>
</li>
</ul>
</div>
</div>
<small id="navbar-node-info"></small>
</div>
</nav>
I think that right-alignment of "Refresh" and "Account" were provided by the "mr-auto" attribute on:
<ul id="navbar-section-list" class="navbar-nav mr-auto">
But sadly I have no idea why it stopped working with "flex"...
I tried adding a justify-content-end on the second ul.navbar-nav but it made no difference, still no right alignment.
here is the jsfiddle for your problem https://codepen.io/irinnahar/pen/JQamQy?editors=1000 you just need to add w-100 to your <div class="d-flex flex-column w-100"> class
<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">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="d-flex flex-column w-100">
<div class="d-md-flex d-block flex-nowrap">
<div class="collapse navbar-collapse">
<ul id="navbar-section-list" class="navbar-nav mr-auto">
... a bunch of li/a here to represent left aligned items
</ul>
<ul class="navbar-nav ">
<li class="nav-item dropdown-item-right">
<a id="refresh-button" class="nav-link" href="#">Refresh</a>
</li>
<li class="nav-item dropdown dropdown-item-right justify-content-end">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Account</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<span id="account-info-header" class="dropdown-item-text"></span>
<a class="dropdown-item">Settings</a>
<a class="dropdown-item" href="/auth/v1/logout">Log out</a>
</div>
</li>
</ul>
</div>
</div>
<small id="navbar-node-info"></small>
</div>
</nav>