mercredi 1 avril 2015

Keeping aspect ratio of image but cropping when hitting max/min height

I'm trying to make this image responsive that it will resize and keep it aspect ratio at all sizes. However above 650px, its height won't increase but will just crop the top and bottom to keep the ratio and not stretch. Also I want the image height won't go below 200px and just the left and right. I want image to always be center too. Here is what I have so far: http://ift.tt/1agniLG



<div class="hero">
<img src="http://ift.tt/1FfeakU">
</div>


.hero {
width: 100%;
min-height:200px;
max-height: 650px;
position: relative;
}
.hero img {
width: 100%;
height:auto;
min-height:200px;
overflow: hidden;
max-height: 650px;
position:aboslute;
}


Many thanks


Aucun commentaire:

Enregistrer un commentaire