1
I have a div that controls the maximum size an image can have. I would like the image to fit the size of the div, without cutting part of it (as in overflow: hide
).
I used the overflow:hide
the image does not exceed the limit of the div.
HTML:
<div id="controlImg">
<img src="img/arroz.jpg">
</div>
CSS:
#controlImg{
max-width: 400px;
max-height: 500px;
border: 1px solid green;}
#controlImg img {
width: 100%;
height: 100%;
}
In the overflow: auto
, a scroll bar is created instead of cutting the image, but I would really like it to adapt to the size of the parent div (controlImg)
In the image, I inserted width:100%
and height:100%
, but the image did not obey, as shown in the image:
max-width: 100%; max-height: 100%;
– Andre Lacomski