我有一个两栏的布局.左图中有一张图片.右图中有两幅图像叠加在一起.我的目标是让图像尽可能地增加,但必须保持它们的纵横比.当然,不能溢出到容纳高度之外.
现在,如果您更改浏览器窗口的宽度,图像将以正确的方式相应地调整大小.但如果减小窗口的高度,图像的大小不会减小.
任何小费. outer-container有高度计算(outer-containervh-outer-containerpx).它应该模拟具有粘性页脚的情况.
.outer-container {
display: flex;
background-color: green;
height: calc(100vh - 100px);
clear: auto;
}
.left-column {
}
.right-column {
display:flex;
justify-content: top;
flex-direction: column;
}
.left-image {
width: 100%;
}
.right-image {
width: 100%;
}
/* Currently using image tag but meant to work with video as well, easier to create a snippet for img though!*/
<div class="outer-container">
<div class="left-column">
<img class="left-image" src="https://via.placeholder.com/200x500/333300">
</div>
<div class="right-column">
<img class="right-image" src="https://via.placeholder.com/500X250/33000">
<img class="right-image" src="https://via.placeholder.com/500x250/003300">
</image>
</div>
</div>