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.
Related
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.
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;;
}
I have written code using bootstrap. But my issue is in the Toggle bar , like when I shrink the size to see my Web page responsive or not then the toggle bar is not open.
It shows the three button but when i click then it is not expanding.
Please give me suggestions to get rid of this issue.
Thanks.
Html code
<section>
<div id="container1">
<nav class="navbar navbar-expand-lg navbar-light bg-dark">
<div class="container-fluid">
<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">
<li class="nav-item">
<a class="scroll nav-link" href="#home" style = "color: #ffff;">HOME</a>
</li>
<li class="nav-item">
<a class="scroll nav-link" href="#about" style = "color: #ffff;">ABOUT</a>
</li>
<li class="nav-item">
<a class="scroll nav-link" href="#services"style = "color: #ffff;">SERVICES</a>
</li>
<li class="nav-item">
<a class="scroll nav-link" href="#contacts" style = "color: #ffff;">CONTACTS</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</section>
**Css code**
#container1{
margin-top:5rem ;
display: inline-block;
width: 100%;
}
#container1 ul li {
margin-left: 8rem;
margin-right: -5rem;
border-right: 0.0625rem solid grey;
}
#container1 ul li a:hover{
background-color: #5e9ee7;
}
I just get rid of my issue that I have arose a few hours ago. I finally got a fix of my problem. It only happens by removing "bs" which is present in between (data-bs-toggle="collapse") and in (data-bs-target="#navbarNav") in the html code.
as posted on the title, I can't change the background-color of my navbar. But I'm sure that my external css is working.
HTML CODE:
<nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
<div class="container">
<a class="navbar-brand" href="{% url 'index' %}"><img src="{{logo.image.url}}" alt="no image provided" style="max-width: 10rem; max-height: 10rem;"></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">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="{% url 'index' %}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'accounts:register' %}">Sign Up</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'cms' %}">Manage Web Content</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'admin:index' %}" tabindex="-1">Admin Page</a>
</li>
</ul>
</div>
</div>
<ul class="sample">
<a class="nav-link" href="#" tabindex="-1">sample</a>
</ul>
</nav>
EXTERNAL CSS:
.navbar {
background-color: black;
}
.sample .nav-link {
color: red;
}
And I will include a picture of my navbar just for reference. Take note of the ul tag with sample label in it, located at the right part of the navbar. It turned out to be red. That's how I knew the external CSS is working. Any ideas why is this happening?
SOLUTION: thanks to those guys who answered in the comment section. And it seems that the problem is one of these classes navbar-light orbg-light , these are default classes from bootstrap framework. So, in order for my external css to work is I needed to put !important to override those 2 classes mentioned above:
.navbar {
background-color: black !important;
}
.sample .nav-link {
color: red;
}
Just Remove bg-light bootstrap class from nav tag and add your custom class over their your result should be like this.
<nav class="navbar navbar-expand-lg navbar-light bg-example sticky-top"></nav>
.bg-example{
background-color:orange;
}
Im trying to get Navigation Link styles like this
In the mobile View active link should be like this =>
For now Using border and border color i got this =>
Respective mobile view
Any solution for get the expected results?
The current code
<nav class="navbar navbar-expand-lg navbar-light ">
<a class="navbar-brand" href="#">
LOGO
</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 justify-content-end" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link " href="#">Home</a>
</li>
<li class="nav-item" >
<a class="nav-link" >Services</a>
</li>
<li class="nav-item" >
<a class="nav-link" >About</a>
</li>
<li class="nav-item" >
<a class="nav-link" >Contact</a>
</li>
</ul>
</div>
</nav>
sass for active link
.navbar-nav > .active a
color: $nav-active-color !important
.navbar-nav > .active
border-top: 3px solid $nav-active-color !important
This would be a good use for the :before or :after psuedo classes, but without having any of your code to go off of I can only offer this vague suggestion.
As well, worth seeing the accepted answer here on a thread about nesting pseudo classes just in case you run into one of the outlined issues.
From there, you could add some keyframes and smooth out the transition to make a pretty seamless hover animation.
div {
width: 350px;
height: 100px;
background: lightgray;
position: relative;
margin: 20px;
}
div:before {
content: '';
width: 60px;
height: 4px;
background: gray;
position: absolute;
top: -4px;
}
<div></div>