I have a couple of images with different aspect ratios and different orientations (vertical / horizontal).
I would like to show them in a grid, with each grid block being 200 pixels wide and 200 pixels wide. I know how to create a grid ("float: left, width: 200px; height: 200px").
How can I put images there? I would like to resize them so that the SHORTEST side becomes 200px of the block, and "crop" (possibly with "overflow: hidden"?) The longer side is also 200px.
Is this possible with just CSS? If not, how would you resolve it? Resize the server so that the longest side is always βrightβ (200 pixels)?
What am I still ...
<div class="grid"> <div class="item"> <img src="pic1.jpg"/> </div> <div class="item"> <img src="pic1.jpg"/> </div> <div class="item"> <img src="pic1.jpg"/> </div> <div class="item"> <img src="pic1.jpg"/> </div> <div class="item"> <img src="pic1.jpg"/> </div> <div class="item"> <img src="pic1.jpg"/> </div> <div class="item"> <img src="pic1.jpg"/> </div> .... </div> .grid { width: 1000px; } .item { width: 200px; height: 200px; float: left; }
source share