html - Why is there a space between the image and the div below? -
i have set scale image full width, cut bottom of when gets high. setup 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 expected when image height on 100px. when image height smaller containers max-height (which 100px) there gap between image , div below. height of image's container div ("top") bigger height of displayed image. can't understand why.
test here: http://jsfiddle.net/lborgman/5mbpv/7/
i doing in latest chrome (version 33.0.1750.154 m) on windows. update: tested firefox. see same thing there. , in ie 11.
update 2: looks gap between #image , #bottom 4px. looks interesting.
the height of image's container div ("top") bigger height of displayed image.
the problem above isn't true. browser up- or down-scales image maintain proportions when set width, in case width:100%. instance, if picture 100x100, box in 300px wide, picture upscaled 300x300, higher container.
Comments
Post a Comment