look, i have a photo (1000px).
(看,我有一张照片(1000px)。)
This photo is flexible. (这张照片很灵活。)
It means when the user's window is less than 1000px photo starts reducing in proportion. (这意味着当用户的窗口小于1000像素时,照片开始按比例缩小。)
So, i want to make a block, that will do the same as photo. (所以,我想做一个方块,它将和照片一样。)
That block should have width
and height
like a photo. (该块应具有与照片一样的width
和height
。)
.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>
ask by slower. translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…