I want to have 3 divs that fluidly respond (scale both width and height maintaining same ratio) to browser width. The majority of my images are vertical so that's why I created as overflow: hidden
because I don't mind to hide portion of the image for very long images - think the screenshot of a website for instance!
However in some cases a few images are shorter, so what to do in that case? Maybe use JS?
This is my code: https://codepen.io/anon/pen/wrygJE
.flex1 {
display: flex;
}
body {
background-color: #ccc;
}
.archives .imageContainer {
position: relative;
width: 100%;
padding-bottom: 70vw;
height: 0;
margin: 30px 0;
margin-bottom: 40px;
overflow: hidden;
border: 10px solid #fff;
}
.archives {
padding: 30px 30px 40px 30px;
width: 100%;
box-sizing: border-box;
font-size: 0;
position: relative;
}
.archives img {
width: 100%;
position: absolute;
left: 0;
}
.archives .imageContainer.half.medium {
width: calc(30% - 15px);
width: -moz- width:calc(30% - 15px);
width: -webkit- width:calc(30% - 15px);
width: -o- width:calc(30% - 15px);
display: inline-block;
margin-left: 30px;
flex-grow: 3;
}
.archives .imageContainer.half.small {
width: calc(15% - 15px);
width: -moz- width:calc(15% - 15px);
width: -webkit- width:calc(15% - 15px);
width: -o- width:calc(15% - 15px);
display: inline-block;
margin-left: 30px;
flex-grow: 3;
}
<div class="archives">
<div class="flex1">
<div id="thumb75" class="imageContainer ">
<img src="https://i.pinimg.com/736x/cd/a2/ca/cda2ca355868d6f28144dfae7b1a6458--web-portfolio-portfolio-website.jpg">
</div>
<div id="thumb76" class="imageContainer half medium">
<img src="https://i.pinimg.com/736x/cd/a2/ca/cda2ca355868d6f28144dfae7b1a6458--web-portfolio-portfolio-website.jpg">
</div>
<div id="thumb77" class="imageContainer half small">
<img src="https://i.pinimg.com/736x/cd/a2/ca/cda2ca355868d6f28144dfae7b1a6458--web-portfolio-portfolio-website.jpg">
</div>
</div>
</div>