My website is built using React and react-strap. I set up my .header-overlay
to cover the entire background within the .header
. However, due to the presence of the .navbar
, the .header-overlay
extends beyond the boundaries of the .header
vertically.
I thought that using
calc(100vh - heightOfNavigationBar)
could fix this issue.
But, I struggled to find a way to dynamically retrieve the height of the .navbar
. Is there a solution for this? (Keep in mind that the navbar is part of react-strap).
CSS CODE:
.navbar {
font-size: 20px;
}
.header {
background: url("../images/headerbg.jpg") no-repeat 50% 50% fixed;
background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
-webkit-background-size: cover;
height: 100vh;
}
.header-overlay {
background-color: rgba(31, 31, 31, 0.4);
height: 100vh;
}
HTML CODE:
<header className="header">
{/*Navigation Bar*/}
<div>
<NavBar/> <--from react-strap
</div>
<div className="header-overlay">
SOME CODE HERE
<div>
</header>