I'm having trouble centering my logo in the navbar. I've looked through other posts, but none of the solutions seem to work without messing something else. I don't understand why the logo won't center and I need the site to be responsive.
<!-- Navigation -->
<nav class="navbar navbar-expand-md navbar-light bg-faded">
<div class="navbar-collapse collapse w-100 order-1 order-md-0 dual-collapse2">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Recruitment</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="events.html">Events</a>
</li>
</ul>
</div>
<div class="mx-auto order-0">
<a class="navbar-brand mx-auto" href="template.html">
<img src = "logo.png" width="100" alt="logo thing">
</a>
</div>
<div class="hamburger-menu">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".dual-collapse2">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="navbar-collapse collapse w-100 order-3 dual-collapse2">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Leadership</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Sisterhood</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Philanthropy</a>
</li>
</ul>
</div>
</nav>
Here's the css for the html.
.navbar>.container .navbar-brand-centered,
.navbar>.container-fluid .navbar-brand-centered {
margin-left: -80px;
position: relative;
float: center;
}
}
.navbar{
font-family: Montserrat;
font-size: 1em;
}
/* change spacing for nav items*/
.navbar-expand-md .navbar-nav .nav-link {
padding-right: 2.5rem;
padding-left: 2.5rem;
}
.nav-item, .navbar-nav{
font-family: Montserrat;
}
.navbar>.container .navbar-brand-centered,
.navbar>.container-fluid .navbar-brand-centered {
margin-left: -80px;
position: relative;
float: center;
}
}
You have an extra breaking bracket after float:center;.
There is no such thing as float:center;
There are a variety of ways to center things. The easiest is to:
.parent-element {
display: flex;
justify-content: center;
}
If the parent is position: relative, you can make the target element position absolute and do this https://codepen.io/anon/pen/EQGgpM:
.parent-element {
position: relative;
width: 200px;
height: 50px;
outline: 1px solid #000;
}
.child {
position: absolute;
outline: 1px solid #cc0000;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
An img element responds to text-align: center just fine.
html, body {
width:100%;
text-align: center;
}
<img src="https://telecomputingarchitects.com/media/logo.png" alt="logo" height="48">
Related
Here I'm designing webpage for my personal project. I have this navbar added in my website, in which I wish to fill the links in navbar fully when I hover mouse pointer over those links. Here I have attached the screenshot of what I'm getting.
The html code for navbar
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light border-bottom box-shadow mb-3">
<div class="container" style="overflow:auto">
<a class="navbar-brand" asp-area="" asp-page="/Index">BookStore</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Books/Index">Books</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
The CSS behind navbar:
html {
position: relative;
min-height: 100%;
margin: 0;
}
body {
background-color: #cccccc;
margin: 0;
/*margin-bottom: 60px;*/
}
nav {
background-color: #8080ff;
margin: 0px;
position: absolute;
}
.navbar-nav {
height: 100%;
margin: 0;
}
Note: I'm designing the web app using ASP.NET in Visual Studio 2022.
Tried to change margin properties of nav class, body class, html class. Tried to set height property to 100%. But nothing worked!!
You should set padding to 0px for the nav element:
nav {
background-color: #8080ff;
margin: 0px;
position: absolute;
padding: 0px !important;
}
This is the answer for "what does !important mean?"
The !important rule in CSS is used to add more importance to a property/value than normal.
In fact, if you use the !important rule, it will override ALL previous styling rules for that specific property on that element!
example:
#id {
background-color: blue;
}
.class {
background-color: gray;
}
p {
background-color: red !important;
}
OR it will prioritize the CSS property. !important have the most priority than anything.
add padding:0px !important to nav selector in CSS
Follow below code
<style>
li.nav-item{
display: contents;
padding: 12px;
margin-right: 12px;
top: 0;
position: absolute;
}
li.nav-item a{
margin-right: 12px;
}
li.nav-item a:hover{
background-color: #cccccc;
/* display: contents; */
padding: 16px;
top: 0;
/* position: absolute; */
}
html {
position: relative;
min-height: 100%;
margin: 0;
}
body {
background-color: #cccccc;
margin: 0;
/*margin-bottom: 60px;*/
}
nav {
background-color: #8080ff;
margin: 0px;
position: absolute;
width: 100%;
}
.navbar-nav {
height: 100%;
margin: 0;
}
ul{
margin-left: 60px !important;
}
</style>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light border-bottom box-shadow mb-3">
<div class="container" style="overflow:auto">
<a class="navbar-brand" asp-area="" asp-page="/Index">BookStore</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Books/Index">Books</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
My bootstrap Navbar is white and despite trying everything i can find on Stack i cant override the white to make it transparent.
I have tried setting the background to transparent
The image behind is set to VH100 so should be behind the nav
I have tried using Inspect and targeting every colour instruction i could find
I removed the bg class from the navbar thinking that would help
Here is my html
<nav class="navbar navbar-expand-sm navbar-light">
<div class="container-fluid">
<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">
<img src="/assets/images/MothersSpinesLogo.png" alt="Mothers Spines MS Logo">
<ul id="nav" class="navbar-nav ms-auto">
<li class="active nav-item">
<a class="nav-link"href="index.html">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">ABOUT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">CONTACT</a>
</li>
</ul>
</nav>
and my CSS;
/* Navigation */
.navbar-brand {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
max-height: 60px;
max-width: 60px;
margin-left: 30px;
}
.navbar {
align-items: end;
background: none;
background-color: rgba(0, 0, 0, 0.0);
--bs-navbar-nav-link-padding-x: 3.5rem;
font-family: 'Montserrat';
font-size: 120%;
list-style-type: none;
letter-spacing: 1px;
--bs-navbar-toggler-border-color: rgba(0, 0, 0, 0.0);
}
.navbar a {
text-decoration: none;
color: #252525;
}
.nav-item {
padding-top: 25px;
}
Screenshot of Nav and Inspect open
.navbar { background-color: transparent; }
Add the following to the image: height: 100vh;, position: absolute; and top: 0;.
If you just set height: 100vh; to the image, the image will be full viewport height, but it will start AFTER the navbar. You want to place it below the navbar. You do this by setting position: absolute; and top: 0;.
In short, the problem is caused by the image.
It looks like there are issues with element placement. Code provided does work for overlaying the image.
img#bg {
position: absolute;
}
/* Navigation */
.navbar-brand {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
max-height: 60px;
max-width: 60px;
margin-left: 30px;
}
.navbar {
align-items: end;
background: none;
background-color: transparent;
--bs-navbar-nav-link-padding-x: 3.5rem;
font-family: 'Montserrat';
font-size: 120%;
list-style-type: none;
letter-spacing: 1px;
--bs-navbar-toggler-border-color: rgba(0, 0, 0, 0.0);
}
.navbar a {
text-decoration: none;
color: #252525;
}
.nav-item {
padding-top: 25px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<img id="bg" src="https://st3.depositphotos.com/1021722/13762/i/600/depositphotos_137623752-stock-photo-art-spring-background-fresh-flower.jpg">
<nav class="navbar navbar-expand-sm navbar-light">
<div class="container-fluid">
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a href="index.html" class="navbar-brand">
<img alt="Mothers Spines MS Logo">
</a>
<ul id="nav" class="navbar-nav ms-auto">
<li class="active nav-item">
<a class="nav-link" href="index.html">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">ABOUT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">CONTACT</a>
</li>
</ul>
</nav>
I'm actually stuck to develop a two-column responsive website. I cannot get my background-image to be responsive and I don't know if my structure is correct.
My first column is called sidebar and the second one - main-content.
HTML:
<body>
<section class="sidebar">
<nav>
<div id="logo" class="container-fluid">
<a class="navbar-brand" href="#"><h1>Coffee Mug</h1></a>
</div>
<div id="navbar" class="container-fluid">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
</section>
<section class="main-content">
<header class="container-fluid">
</header>
</section>
</body>
CSS:
.sidebar
{
position: fixed;
float: left;
width: 25%;
height: 100% !important;
background-color: #93AF79 !important;
}
#logo
{
margin: 80px 100px;
}
#navbar ul li
{
text-align: center;
}
#main-content
{
width: 85%;
}
header
{
background: url("Coffee_mug2.png") no-repeat;
background-size: cover;
/* max-width: 100%; */
height: 600px;
}
What am I doing wrong?
Oh, so you mean like this?
body {
margin: 0;
padding: 0;
}
.sidebar {
position: fixed;
float: left;
width: 25%;
height: 100% !important;
background-color: #93AF79 !important;
}
#logo {
margin: 80px 100px;
}
#navbar ul li {
text-align: center;
}
#main-content {
width: 75%;
}
header {
background: url("https://sd-1.archive-host.com/membres/images/210138792344645661/Coffee_mug2.png") no-repeat;
background-size: cover;
background-position: top center;
height: 600px;
}
main {
height: 1000px;
}
<section class="sidebar">
<nav>
<div id="logo" class="container-fluid">
<a class="navbar-brand" href="#">
<h1>Coffee Mug</h1>
</a>
</div>
<div id="navbar" class="container-fluid">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
</section>
<section class="main-content">
<header class="container-fluid"></header>
<main>content content content</main>
</section>
Looks like it's a misuse of the background shorthand property, the following change should get it done for you:
header{
background: no-repeat url("https://sd-1.archive-host.com/membres/images/210138792344645661/Coffee_mug2.png") ;
background-size: contain;
height: 600px;
}
I was trying to convert PSD to Html and i got a little problem solving this issue. Take a look at the image below:
As I've mentioned with the red arrow, there is a blue background image in the header of the template! how can I add this background with a responsive and stable position even if the browser size changes? The background should always contain 70% of the screen (ends between the logo and the first nav-item).
Here is the jsfiddle of my work: https://jsfiddle.net/4dpgbLt9/2/
html,
body {
height: 100%;
}
body {
font-family: IranSans, sans-serif;
}
.header {
height: 100vh;
width: 100vh;
background: url("https://i.imgur.com/aN7jCZE.png") left no-repeat;
background-size: contain;
}
.navbar {
direction: rtl;
padding-top: 16px;
}
.nav-item .nav-link {
font-size: 16px;
padding: 0 20px 0 20px !important;
}
.nav-item.active .nav-link {
color: #ffd738 !important;
}
.nav-item .nav-link {
color: #ffffff !important;
}
.nav-account-parent {
position: relative;
}
.nav-account {
position: absolute;
width: 100%;
height: 100px;
top: -50px;
z-index: -1;
background-color: #025c64;
border-radius: 16px;
}
.navbar-brand img {
width: 220px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<html lang="en">
<body>
<nav class="navbar navbar-expand-md navbar-light bg-transparent justify-content-center">
<div class="container">
<a class="navbar-brand" href="#">
<img src="https://i.imgur.com/gURHBju.png" alt="Logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">صفحه اصلی</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">درباره ما</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">درخواست مشاوره</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">خدمات</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">فروشگاه</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ارتباط با ما</a>
</li>
<li class="nav-item nav-account-parent">
<div class="nav-account"></div>
<a class="nav-link" href="#">ورود / عضویت</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="header">
</div>
Thanks for your time ♥
This is my solution:
Change .header width from 100vw to 100%
Change background-size from contain to 70% within .header
Add top to background: to anchor it to the top left
CSS:
.header {
height: 100vh;
width: 100%;
background: url("https://i.imgur.com/aN7jCZE.png") top left no-repeat;
background-size: contain;
background-size: 70%;
}
codepen: https://codepen.io/CodeBoyCode/pen/VEEoQW
I'm trying to create a double layered navbar, with the top layer having company info like phone, email, social links, etc.
The second layer is the main navbar, which is supposed to be sticky and transparent.
But right now, it's pushing the next div (first) down and creating this blank space instead of hovering on top of the div. I can't really find the fault with it. I'm using Bootstrap 4.
#top-nav{
position: relative;
z-index: 1000;
}
.top-nav{
background-color: #FFF;
height: 40px;
}
.top-nav a{
color:#696969;
}
.top-nav a:hover{
color:#FF6700;
}
.top-nav p{
margin-left: 50px;
position: relative;
top:5px;
color: #696969;
}
.top-nav .social-links a{
padding-right: 20px !important;
position: relative;
top: 5px;
color: #696969;
}
.top-nav .social-links a:hover{
color: #ff6700;
}
#content{
height:100%;
width:100%;
}
.navbar-brand img{
width: 300px ;
height: auto ;
}
#media screen and (max-width:500px){
.navbar-brand img{
width:250px;
}
#content{
/* top: - */
}
}
#media screen and (min-width: 500px){
.navbar-brand img{
margin-left: 20px;
}
}
.first{
height: 100vh;
background-color: #000;
position: relative;
z-index:0;
/* position:relative;
top:-115px; */
}
.second{
min-height: 100vh;
background-color: #676767;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div id="top-nav" class="container-fluid text-center">
<div class="container row top-nav justify-content-between ml-auto mr-auto">
<div class="call .col-auto mr-auto">
<p><b>Contact: </b>+111111111</p>
</div>
<div class="call .col-auto mr-auto">
<p><b>Email: </b>contact#axyz.com</p>
</div>
<div class="col-auto social-links">
<i class = "fab fa-facebook-f"></i>
<i class = "fab fa-skype"></i>
<i class = "fab fa-linkedin-in"></i>
</div>
</div>
</div>
<nav class="navbar navbar-expand-md navbar-dark bg-transparent sticky-top">
<a class="navbar-brand" href="index.html">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<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="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Career</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
<div class="first"></div>
<div class="second"></div>
A sticky positioned element will take up it's space as it is positioned relatively until it is scrolled past and becomes sticky (then it doesn't say what should happen to that space).
Not sure if what the below is after, but I have just moved the sticky class onto a separate container div and given that a height of 0 with overflow visible, that way it doesn't take up any space
#top-nav{
position: relative;
z-index: 1000;
}
.top-nav{
background-color: #FFF;
height: 40px;
}
.top-nav a{
color:#696969;
}
.top-nav a:hover{
color:#FF6700;
}
.top-nav p{
margin-left: 50px;
position: relative;
top:5px;
color: #696969;
}
.top-nav .social-links a{
padding-right: 20px !important;
position: relative;
top: 5px;
color: #696969;
}
.top-nav .social-links a:hover{
color: #ff6700;
}
#content{
height:100%;
width:100%;
}
.navbar-brand img{
width: 300px ;
height: auto ;
}
#media screen and (max-width:500px){
.navbar-brand img{
width:250px;
}
#content{
/* top: - */
}
}
#media screen and (min-width: 500px){
.navbar-brand img{
margin-left: 20px;
}
}
.first{
height: 100vh;
background-color: #000;
position: relative;
z-index:0;
/* position:relative;
top:-115px; */
}
.second{
min-height: 100vh;
background-color: #676767;
}
.sticky-top {
height:0;
overflow:visible;
box-sizing:border-box;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div id="top-nav" class="container-fluid text-center">
<div class="container row top-nav justify-content-between ml-auto mr-auto">
<div class="call .col-auto mr-auto">
<p><b>Contact: </b>+111111111</p>
</div>
<div class="call .col-auto mr-auto">
<p><b>Email: </b>contact#axyz.com</p>
</div>
<div class="col-auto social-links">
<i class = "fab fa-facebook-f"></i>
<i class = "fab fa-skype"></i>
<i class = "fab fa-linkedin-in"></i>
</div>
</div>
</div>
<div class="sticky-top">
<nav class="navbar navbar-expand-md navbar-dark bg-transparent">
<a class="navbar-brand" href="index.html">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<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="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Career</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
</div>
<div class="first"></div>
<div class="second"></div>
https://developer.mozilla.org/en-US/docs/Web/CSS/position
Instead of using sticky-top use fixed-top, the sticky property will maintain the space of the element in the normal flow that is why you see that space..
#top-nav{
position: relative;
z-index: 1000;
}
.top-nav{
background-color: #FFF;
height: 40px;
}
.top-nav a{
color:#696969;
}
.top-nav a:hover{
color:#FF6700;
}
.top-nav p{
margin-left: 50px;
position: relative;
top:5px;
color: #696969;
}
.top-nav .social-links a{
padding-right: 20px !important;
position: relative;
top: 5px;
color: #696969;
}
.top-nav .social-links a:hover{
color: #ff6700;
}
#content{
height:100%;
width:100%;
}
.navbar-brand img{
width: 300px ;
height: auto ;
}
#media screen and (max-width:500px){
.navbar-brand img{
width:250px;
}
#content{
/* top: - */
}
}
#media screen and (min-width: 500px){
.navbar-brand img{
margin-left: 20px;
}
}
.first{
height: 100vh;
background-color: #000;
position: relative;
z-index:0;
/* position:relative;
top:-115px; */
}
.second{
min-height: 100vh;
background-color: #676767;
}
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700%7CRoboto%7CJosefin+Sans:100,300,400,500" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/fa-svg-with-js.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="css/normalise.css">
<link rel="stylesheet" href="css/style.css">
<div id="top-nav" class="container-fluid text-center">
<div class="container row top-nav justify-content-between ml-auto mr-auto">
<div class="call .col-auto mr-auto">
<p><b>Contact: </b>+111111111</p>
</div>
<div class="call .col-auto mr-auto">
<p><b>Email: </b>contact#axyz.com</p>
</div>
<div class="col-auto social-links">
<i class = "fab fa-facebook-f"></i>
<i class = "fab fa-skype"></i>
<i class = "fab fa-linkedin-in"></i>
</div>
</div>
</div>
<nav class="navbar navbar-expand-md navbar-dark bg-transparent fixed-top">
<a class="navbar-brand" href="index.html">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<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="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Career</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
<div class="first"></div>
<div class="second"></div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="js/fontawesome-all.min.js"></script>
If you want the 2nd navbar background to be transparent, you have to make the sure the color of content in the navbar can be seen over the different background colors...
.sticky-top .navbar-nav .nav-link,
.sticky-top .navbar-nav .active .nav-link {
color: #cc00dd;
}
https://www.codeply.com/go/ypn9gieMza