The task is to create a div class, the image is a background, its height depends on the content. I will name this block - Main. Next: the second div is a black color with translucency to darken the main unit. I will name it - Fading. I managed to impose it, but here the problem is obscured and the text that is inside the Main unit. I tried to enter the text inside the Dimming block, but in this case the Main block does not stretch along the height of the contents. Looking for a whole day, I think how to solve this problem. It is necessary that the text was in the uppermost layer and the image is dark. Now what:
.main { background-image: url('images/background.jpg'); z-index: 1; background-size: 100% 100%; position: relative; color: white; font-size: 14px; text-align: center; } .blackout { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-color: rgba(0, 0, 0, 0.5); z-index: 10; width: 100%; height: 100% ; } <div class="main"> <div class="blackout"></div> </div>