I tried to find out if there is a pure CSS solution so that the image inside my banner does not fall below the height of the parent, but maintains the image ratio.
Here you can see the demo: http://jsfiddle.net/LkxYU/1/
HTML:
<div class="banner_holder"> <img src="http://placekitten.com/g/800/600"/> </div>
CSS
.banner_holder{ width: 100%; height: 300px; min-height: 200px; position: relative; outline:1px dotted red; } .banner_holder img{ width: 100%; }
My goal is to always have an image 100%, but not lower than 300 pixels high. This will mean cropping the image, but it's fine, I just want to know if there is a clean CSS solution or if I need to use jQuery
source share