I found a solution that fixes the issue, although there’s still a thin white line showing below the navigation bar.
But overall, it works well for me — the navigation bar starts off transparent, and then changes to a solid color when you scroll down the page.
Here’s the code I used:
CSS (for transparent header that changes on scroll)
/* Transparent header setup */
.softr-topbar {
background: transparent !important; /* Makes the background clear */
box-shadow: none !important; /* Removes any shadow at the top */
position: fixed !important; /* Keeps the header fixed at the top */
top: 0;
left: 0;
right: 0;
width: 100%;
z-index: 9999; /* Ensures it stays above everything else */
transition: background-color 0.3s ease, box-shadow 0.3s ease;
border-bottom: none !important; /* Removes any bottom border */
}
/* Optional: style links/buttons when header is transparent */
.softr-topbar a,
.softr-topbar .button {
/* color: white !important; */ /* Uncomment this if your background is dark */
transition: color 0.3s ease;
}
/* When you scroll past a certain point */
.softr-topbar.scrolled {
background-color: var(--color-primary) !important; /* Changes to solid background */
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important; /* Adds a subtle shadow */
}
/* Changes link/button colors for visibility after scroll */
.softr-topbar.scrolled a,
.softr-topbar.scrolled .button {
color: #000000 !important; /* Makes text dark for better contrast */
}
JavaScript (to trigger the scroll effect)
<script>
window.addEventListener("scroll", function () {
const topbar = document.querySelector(".softr-topbar");
const scrollThreshold = 200; // Adjust this number to set when the nav changes
if (window.scrollY > scrollThreshold) {
topbar.classList.add("scrolled");
} else {
topbar.classList.remove("scrolled");
}
});
</script>