Navbar items don't stay fixed when I open the overflow-toggler - html

Preface - I am not asking about "navbar-fixed-top"
I am trying to make simple Navbar with a custom height.
HTML code:
<nav class="navbar navbar-expand-md">
<div class="container-fluid nav-bar">
<a class="navbar-brand" href="#">Navbar</a>
<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">H</span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav ms-auto">
<a class="nav-link" href="#">HOME</a>
<a class="nav-link" href="#">DESTINATIONS</a>
<a class="nav-link" href="#">CREW</a>
<a class="nav-link" href="#">TECHNOLOGIES</a>
</div>
</div>
</div>
</nav>
CSS code:
.navbar {
background-color: orange;
height: 72px !important;
}
a {
color: #000;
}
Here's the Codeply link: https://www.codeply.com/p/mBsxyw02Q3
When opening the Overflow menu (or toggler in Bootstrap language) - the 'Nav-brand' along with other elements in the Navigation bar displace upwards to show the hidden elements.
Something about me - I just started out Web Dev, so I just know a handful of things about HTML and CSS. I understand that the issue here maybe happening because of script, but I am not sure. So let me know if this issue can be corrected with CSS and how. If not, is it related to javascript?
I have inspected the page for any changes in padding or margin when I open the hamburger menu, but there's no changes so I am kind of out of idea what might be happening here.

You need add few lines of code to resolve this issue.
.navigation {
background-color: orange;
min-height: 72px !important;
}
.navbar-brand {
min-height: 55px;
line-height: 48px;;
}

Related

Css wont apply to bootstrap navbar

Below is a snippet of code from my html and css files on a website.
I want the navbar to be slightly transparent and the links to be centered on the navbar but my css wont apply to the navbar, just unsure why.
HTML
<body>
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<!--Navigation bar-->
<nav class="navbar navbar-expand-md bg-dark navbar-dark transparent" id="navbar">
<a class="navbar-brand" href="index.html">
<img src="images/DallE_Extendo-removebg.png" width="80" height="60" alt="">
</a>
<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="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="aboutus.html">About us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="products.html">Products</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contactus.html">Contact us</a>
</li>
</ul>
</div>
</nav>
<!--NavBar Ends-->
<img src="images/ShopInsideBooking (4).png" class="img-fluid" alt="Responsive image">
</div>
</div>
</div>
</body>
CSS
#navbar{
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
}
Any help is appreciated :)
Right.
First thing you need is the good old !important on the background-color because bootstrap already have a bunch of styles and you won't be able to override them without it.
That fixes your issue with the transparency. You can also use opacity instead of background color if you're not changing the current color and the result is acceptable.
For the aligning of things, bootstrap has a few flex features (if you're using BS5) and you can make use of them.
One thing that I would do is to remove the <nav> from the div/row/col stuff because divs are not flex by design so you'll have to change the display of several elements or even add hacks with auto margin to get the output. Add the container directly on nav or navbar items, whatever you feel is suitable but remove the row/col because since it's a nav I'm assuming is the main nav.
Ok.
Once you remove the div/row/col you can just set the nav#navbar as flex and add a margin: 0 auto to it.
Like this https://jsfiddle.net/x1c0yanr/
nav#navbar {
background-color:rgba(0,0,0,0.5) !important;
}
nav#navbar ul.navbar-nav {
display: flex;
margin: 0 auto;
}
EDIT: I realized after answering that you're using bootstrap 4 so I tested using BS4.4.1 as well. It works :D Take a look at flex. aligning, arranging, ordering. It's amazingly easy to to things using it. Here using BS4.4.1: https://jsfiddle.net/v3dn8cqu/

I don't know add picture to my company to the navbar - angular12

I can't add logo to the navbar on my angular website.
HTML:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" routerLink=""><img src="/src/assets/images/Nikiikejks.png" alt=""></a>
<button class="navbar-toggler" 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="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link active" routerLink="" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}">Domov</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="menu" routerLinkActive="active-link">Menu</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="about" routerLinkActive="active-link">O nás</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="contact" routerLinkActive="active-link">Kontakt</a>
</li>
</ul>
</div>
</div>
</nav>
CSS:
.navbar-light .navbar-nav .nav-link
{
color: var(--secondary-color);
}
.navbar-light .navbar-nav .nav-link.active-link
{
color: #64cff7;
}
.navbar
{
background-color: #f7dfde;
box-shadow: 0px 2px 5px #777 ;
}
.navbar-brand {
width:150px;
font-size: 24px;
}
.navbar-brand img {
height: 30px;
/* put value of image height as your need */
float: left;
margin-right: 7px;
}
I tried add path image and in css add some parameters, but it doesn't works.
I don't know, if I have bad size of picture or what?
Thank you.
It is not the image quality. It has nothing to do with making it functional or not. When img is not shown you either have a wrong path (instead of /src/assets you need assets/etc) or wrong extension (your image is .png and not .jpg or the other way around)
I believe you need to leave the folder app first, and after that, go to the assets.
I don't know your folder structure, but if you currently are on app.component or in the folder app, your path should be: ../assets/images/Nikiikejks.png.

Navbar logo won't appear (bootstrap/django)

Hello I'm trying to add a logo to my navbar but it won't show up. I've looked at other's questions on this matter but I still can't make it show up.
I'm not sure whether the problem is with my code or my image.
I have added the image into the same directory as my code.
My code is as below
.navbar li a {
background-image: "/app/static/app/images/logoa.png";
}
.search {
list-style: none;
padding: 0;
width: fit-content;
border: 0px;
/*border added to visualise collision box*/
}
.search-bar {
display: none;
}
.search-icon {
width: fit-content;
border: 0px;
/*border added to visualise collision box*/
}
.search-icon:hover+.search-bar {
display: block;
}
.search-bar:hover {
display: block;
}
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<img src="/app/templates/logoa.png" alt="computer display with dna in it" width="30" height="24" class="d-inline-block align-text-top">
<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 class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-link active" aria-current="page" href="#">homepage</a>
<a class="nav-link" href="#">form</a>
<a class="nav-link disabled" href="#">workflow</a>
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">tools</a>
</div>
<ul class="search">
<li class="search-icon"><i class="fas fa-search" style="position:absolute; right:10px;"></i></li>
<li class="search-bar" style="position:absolute; right:10px;"><input placeholder="enter search" action=""></li>
</ul>
</div>
</div>
</nav>
edit;;
if i try to follow the path i set in the code it leads me to the image (in visual studio code)
but it can't find it in the browser console
help.png:1 Failed to load resource: the server responded with a >status of 404 (Not Found)
I had the same issue. What worked for me was removing the extension that I was using for the image (.svg) and let Visual Studio code suggest/pick the right extension/path (.jpg).
I had a similar issue. In the .html page, instead of: <img src="/app/templates/logoa.png" try rendering the image with this path instead: <img src="{% static 'app/templates/logoa.png' %}" This syntax is more "Django friendly". Hope this helps.

padding in bootstrap using container fluid

can anyone help me find a bug in bootstrap container fluid which i just need to add some padding but not working
the code only works when we use
.container-fluid {
padding: 3% 15% !important;
}
if we remove !important it is not working do you know the reason
i will share the code below
<body>
<section id="title">
<div class="container-fluid">
<!-- Nav Bar -->
<nav class="navbar navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="">Tindog</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="">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>
</nav>
<!-- Title -->
<div class="row">
<div class="col-lg-6">
<h1>Meet new and interesting dogs nearby.</h1>
<button type="button">Download</button>
<button type="button">Download</button>
</div>
<div class="col-lg-6">
<img src="images/iphone6.png" alt="iphone-mockup" />
</div>
</div>
</div>
</section>
the css code is
#title {
background-color: #ff4c78;
}
.container-fluid {
padding: 3% 15%;
}
h1 {
font-family: "Montserrat", sans-serif;
font-size: 3rem;
line-height: 1.5rem;
}
This usually happens if you've placed the link to your own custom style sheet or defined custom CSS styles inside the <style> tag before linking the style sheet of Bootstrap. The browser follows a top-down approach while rendering the pages and so any CSS styles that share the same name (in your case: .container-fluid) with the style of another style sheet, then your custom CSS styles will be overwritten by the styles in the last style sheet.
Solution: Place the link to your custom style sheet after linking all the other style sheets like that of Bootstrap, Font Awesome, etc.
If you could include the code that you put in between the <head> tag, I could confirm this.
P.S. I see you're doing the TinDog project so you're probably following Angela Yu's course. Here's the GitHub link to my code for reference.

Bootstrap - Nav bar not working correctly

In my project, I implement bootstrap. I also make use of the full navbar that bootstrap provides. I set a custom colour and height to this navbar. When making the browser window smaller, the hamburger icon appears as expected.
When pressing the hamburger icon, none of the menu items appear. I discover that if I make my navbar larger in height, the menu items appear below. However I want the navbar to stay the height it currently is.
Does Anybody know how to move the menu items, maybe to the right to allow them to be seen when the hamburger icon is pressed? This is of course without changing the height of the navbar. Thank you.
Here is my existing code:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<!-- <a class="navbar-brand" href="#">Navbar</a> -->
<div class="imageDiv">
<img class="navbar-brand barberImg" src="{% static 'icon.png' %}" width="63px" alt="Image of man getting haircut">
</div>
<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="#" style="color: white; margin-left: 100px;">Home <span class="sr-only">(current)</span></a>
</ul>
</div>
</nav>
.navbar{
background-image: none;
background-color: #191919 !important;
height: 4.9em;
}
.imageDiv {
background-color: #CED0CE;
width: 98px;
height: 80px;
position: relative;
margin-top: -1px;
margin-left: -16px;
}
.barberImg {
position: relative;
bottom: 6px;
left: 15px;
}
#media screen and (max-width: 991px) {
.imageDiv {
position: relative;
bottom: 8px;
}
}