I want to wrap the image in html DIV, and since I want it to be fully scalable with the window size, I want to set the DIVpercentage width as follows:
HTML
<div id="wrapper">
<img src="http://openclipart.org/people/netalloy/rally-car.svg" />
</div>
CSS
#wrapper {
position: absolute;
width: 50%;
}
#wrapper img {
width: 100%;
}
The image should determine the height of its container. This is due to the fact that the image width is set to 100%, and the image height is calculated accordingly, maintaining the correct aspect ratio.
The result is displayed on jsfiddle: http://jsfiddle.net/lorenzopolidori/5BN4g/15/
My questions:
- Why do all modern browsers display a
DIV5px shell higher than the internal image? - 5px-, javascript?
, Chrome (21.0.1180.89), Firefox (15.0.1) IE8, IE7 , DIV .