look, i have a photo (1000px). This photo is flexible. It means when the user's window is less than 1000px photo starts reducing in proportion. So, i want to make a block, that will do the same as photo. That block should have width
and height
like a photo.
.img_random{
margin-left: 50%;
transform: translate(-50%);
position: absolute;
max-width: 1057px;
width: 95%;
}
.img_random img{
width: 100%;
}
.block-that-should-be-like-a-photo{
position: absolute;
max-width: 1057px;
height: 621px;
width: 95%;
background-color: red;
opacity: 0.5;
margin-left: 50%;
transform: translate(-50%);
}
<div class="img_random"><img src="https://sun9-14.userapi.com/c857536/v857536576/10ef5e/WDQSe10CrOs.jpg" alt="A random photo"></div><div class="block-that-should-be-like-a-photo"></div>