After searching both Stack Overflow and Google I still wonder how to vertical center a image that is bigger than it's parent element. I use no height, just max-height, because I want to make a responsive solution, without jQuery. If possible.
Here is some code:
<div style="max-height: 425px; overflow: hidden;">
<img src="http://img.youtube.com/vi/jofNR_WkoCE/maxresdefault.jpg">
</div>
to center vertically an bigger image u can use the construction and css bellow
And css:
FIDDLE
if you want to make a responsive image, try using
<div style="">
<img src="http://img.youtube.com/vi/jofNR_WkoCE/maxresdefault.jpg" width="100%" height="100%">
</div>
I found a way to make it work with only a
max-height
(as opposed to a fixed height) set on the container.The bad news is that it requires an additional wrapper element.
HTML:
CSS:
Try
If you dont need to use
img
tags (fiddle):CSS
HTML