I am trying to make a div that overlays another div to make the background image appear darker. It works, but instead of making the image darker, everything is darker, such as the text. Even though the overlay div is before the other divs that have the text elements inside of them
Here's a snippet that show what's happening:
.header {
background: url("http://mediad.publicbroadcasting.net/p/wamc/files/201609/codingsnippet.jpg") no-repeat center center fixed;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-repeat: no-repeat;
color: white;
width: 100%;
height: 100%;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
width: 100%;
height: 100%;
background: rgba(0,0,0,.5);
opacity: 0.5;
}
.heading {
display: inline-block;
font-size: 3em;
}
.nav-item {
font-size: 1.3em;
float: right;
list-style-type: none;
padding: 0px 5px;
}
.nav-item > a {
color: white;
font-weight: bold;
display: block;
}
a {
color: black;
text-decoration: none;
}
<div class="header">
<div class="overlay"></div>
<div class="nav">
<!-- <img src="img/logo.png" alt="logo" class="logo"> -->
<li class="nav-item"><a href="https://jordanbaron.github.io">Home</a></li>
<li class="nav-item"><a href="#about" >About</a></li>
<li class="nav-item"><a href="#portfolio" >Portfolio</a></li>
<li class="nav-item"><a href="#contact">Contact</a></li>
</div>
<h1 class="heading" id="heading"></h1>
</div>