Here is what I have:
.container { margin: 30px; } .container div { width: 140px; height: 140px; position: relative; border: 2px solid red; display: inline-block; margin: 0 30px; vertical-align: top; } div img { background: blue; position: absolute; top: 0; bottom: 0; margin: auto; width: 140px; } <div class='container'> <div> <img src="https://farm2.staticflickr.com/1714/25563378972_4eaa0b6812_z.jpg" /> </div> <div> <img src="https://farm9.staticflickr.com/8741/17481366771_4817578296_z.jpg" /> </div> </div> But what I want to get:
That is, the visible part of the horizontal image should also be in the center. I use overflow: hidden and hide the extra part of the image.
