I have set up to scale an image to full width, but cut the bottom of it when it gets to high. The setup is this:
div, img, body {
margin: 0;
padding: 0;
}
#image {
width: 100%;
height: auto;
}
#top {
max-height: 100px;
width: 100%;
}
#bottom {
height: 200px;
width: 100%;
background: green;
}
body { background: yellow; }
This looks as expected when the image height is over 100px. However when the image height is smaller than the containers max-height (which is 100px) there is a gap between the image and the div below. The height of the image's container div ("top") is bigger than the height of displayed image. I can't understand why.
Test it here: http://jsfiddle.net/lborgman/5mBPv/7/
I am doing this in latest Chrome (Version 33.0.1750.154 m) on Windows. UPDATE: Just tested i Firefox. I see the same thing there. And in IE 11.
UPDATE 2: It looks like the gap between #image and #bottom is always 4px. That looks interesting.