Scenario
I managed to develop a transparent navbar that is superimposed on top of a header image with an SVG curve attached to it.
To create the transparent navbar, I modified some classes associated with it by removing bg-light
.
By adding the class fixed-top
, I placed the navbar on top of the header image effectively.
Challenge
The use of fixed-top
makes the navbar appear above the header image, but as the user scrolls down, it sticks like a frozen row in Excel obstructing other content. I desire the transparent navbar to stay static and always display at the page's top. What modifications are required to achieve this?
Reference CodePen https://codepen.io/lowdowner/pen/gOdGVzx
/* Custom CSS */
.svg-container {
position: absolute;
bottom: 0;
height: 0;
width: 100%;
padding-bottom: calc(100% * 45 / 1440);
}
/* PAGE SETUP */
header {
position: relative;
display: flex;
align-items: center;
justify-content: center;
height: 650px;
background-image: url('https://images.unsplash.com/photo-1518837695005-2083093ee35b?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=53b711edbf0f887b5de376f91052d8f8&auto=format&fit=crop&w=1350&q=80');
background-size: cover;
background-position: center;
}
#title {
font-family: 'Knewave', cursive;
font-size: 8rem;
color: #fff;
letter-spacing: 16px;
}
h1,
h2 {
text-transform: uppercase;
}
h1,
h2 {
margin-top: 1.25em;
font-size: 3rem;
}
h1,
h2,
p {
font-family: 'Montserrat', sans-serif;
text-align: center;
}
h2,
a {
color: #3086B9;
}
a {
text-decoration: none;
}
.navbar {
position: fixed;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
z-index: 9999;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8be9e4e4fff8fff9eafbcbbea5b8a5bba6eae7fbe3eaba">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<!-- Wave Start -->
<header>
<nav class="navbar navbar-expand-lg navbar-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
<h1 id="title">Waves</h1>
<div class="svg-container">
<svg id="wave" viewBox="0 0 1440 45" xmlns="http://www.w3.org/2000/svg">
<path d="M0 39C0 39 291.625 0.0315932 479.5 0 667.764 -0.0316586 771.789 34.5337 960 39 1147.5 43.4495 1440 23 1440 23V45H0V39Z" fill="white"/>
</svg>
</div>
</header>
<!-- Wave End -->
<h1>LOREM IPSUM</h1>
<h2>LOREUM IPSUM</h2>
<p>LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM </p>
<p>LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM </p>
<p>LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM LOREM IPSUM </p>