I'm having trouble creating an image that stays inside a div, maintaining its proportions. However the div has a default size, and can not exceed this limit size.
Below is an image that illustrates my intention:
Below is the code in css that I made, the image continues in its defaults, however it is not limited in the div, often surpassing the desired size that fits on the screen:
#div{
padding-top: 20px;
padding-bottom: 20px;
width: 50%;
height: auto ;
}
#imagem{
width: auto;
height: auto;
top: 5%;
left: 26%;
}
Possibly the code is without much sense since I'm programming the web soon.