How to restrict the height of an image to its parent container whose height is specified in terms of percentages?
I want the image to span over the parent if image width/height > parent width/height. and image to be center aligned to parent if image width/height < parent width/height. In any case I dont want the image to be stretched[vertically/horizontall.]
html, body{
width:100%;
height:100%;
}
#top{
height:10%;
}
#middle{
height:80%;
}
#bottom{
height:10%;
}
img{
width: how much?
height: how much?
}
<html>
<body>
<div id="top">I am top</div>
<div id="middle">
<img src="/images/abc.jpg" />
</div>
<div id="bottom">I am bottom</div>
</body>
</html>