I want to add an opacity background, with a visible text in front of an image. In my case I used flex to display the div elements, and I tried to create a background with opacity and also with text for each div. I know that I should use z-index to create background opacity layer, but in my case I don't know why it doesn't work.
main{
border: 2px solid red;
width: 100%;
height: 100vh;
}
.projects-wrapper{
border: 2px solid black;
width: 100%;
height: 50vh;
display: flex;
}
.projects-wrapper div{
border: 2px solid green;
flex-grow: 1;
}
/* .projects-wrapper div.text-description{
border: 2px solid yellow;
font-family: 'Open Sans', sans-serif;
font-size: 20px;
color: white;
text-transform: uppercase;
}
.projects-wrapper div.text-description span{
display: block;
} */
.first-row div:first-child{
background-image: url(../assets/concert-hall.jpg);
background-size: cover;
background-position: center;
}
.first-row div:nth-child(2){
background-image: url(../assets/bedroom-2.jpg);
background-size: cover;
background-position: center;
}
.first-row div:last-child{
background-image: url(../assets/hotel.jpg);
background-size: cover;
background-position: center;
}
<main>
<div class="projects-wrapper first-row">
<div class="image-wrapper">
<!-- <div class="text-description">
Concert hall <span>in New York</span>
</div>
<div class="text-category">
Architecture
</div> -->
</div>
<div class="image-wpapper">
<!-- <div class="text-description">
Modern bedroom <span>in Gorizia</span>
</div>
<div class="text-category">
Interior
</div> -->
</div>
<div class="image-wpapper">
<!-- <div class="text-description">
Modern hotel <span>in London</span>
</div>
<div class="text-category">
Architecture
</div> -->
</div>
</div>
<main>