I am working with a div that contains variously-sized images and is nested inside a parent container.
<div id="parentContainer">
<div id="boxToScale">
<img src="http://placehold.it/350x150" />
<img src="http://placehold.it/150x350" />
<img src="http://placehold.it/200x200" />
<img src="http://placehold.it/50x200" />
</div>
</div>
My goal is to scale #boxToScale
so that it fits perfectly inside #parentContainer
in terms of both width and height, while still maintaining the aspect ratios of all images inside. The scaling factor should be consistent for all images, and they should remain on the same line.
You can see the current setup on jsfiddle here: http://jsfiddle.net/32sm4/
I have tried to find solutions for scaling multiple images proportionally, but most resources only cover scaling a single image. Since I do not know the exact sizes of the images beforehand, only the size of #parentContainer
, I am seeking assistance in achieving this through JavaScript/jquery or CSS if possible. Thank you!
Edit: Here is an example of how I envision the layout after scaling #boxToScale
: