I am seeking assistance in creating a responsive Navbar that transitions from transparent to solid when the screen size changes, such as on a smartphone. I want the Navbar to remain fixed at the top of the page and not move down as I scroll. I tried adding the "bg-dark" class but this removes the transparency. Here is my current code:
#main {
position: relative;
background: url('https://images.template.net/wp-content/uploads/2016/10/15125202/Beautiful-Travel-Photography.jpg?width=600');
min-height: 100vh;
background-size: cover;
background-position: center;
padding: 220px 0 200px;
}
#header {
position: absolute;
z-index: 10;
width: 100%;
}
.navbar-dark .navbar-brand {
color: #ffffff;
}
.nav-item {
font-weight: bold;
text-transform: uppercase;
padding-left: 10px;
}
.navbar-dark .navbar-nav .nav-item .nav-link:hover {
background: #bbbbbb;
color: #ffffff;
}
.navbar-nav > li {
margin-top: 7px;
padding-left: 10px;
padding-right: 10px;
}
.navbar-brand {
color: #fff;
margin-top: 5px;
font-size: 25px;
text-transform: uppercase;
font-weight: bold;
opacity: 0.9;
letter-spacing: 2px;
}
.navbar-brand:hover {
color: grey;
}
.fa {
margin-top: 5px;
}
.fa:hover {
opacity: 0.7;
}
.fa-facebook {
color: white;
}
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x...
</link>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
</link>
<link rel="stylesheet" href="../css/style.css" />
<title>Landing Page</title>
</head>
<body>
<section id="header">
<div class="container-fluid">
<nav class="navbar navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="#">Landing Page</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNavDropdown"
aria-controls="navbarNavDropdown"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<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="#">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link px-2" href="#"><span class="fa fa-facebook"></span></a>
</li>
</ul>
</div>
</nav>
</div>
</section>
<section id="main">
<div class="container">
<div class="row">
<div class="col-md-5 text-white">
<h1>Landing Page</h1>
<h3>
Welcome to my website
</h3>
</div>
</div>
</div>
</section>
<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="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script>
$(function() {
$("#myCarousel").carousel();
});
</script>
</body>
I am aiming for a design similar to this website: