I am facing an issue with a div containing two images. I want the second image to adjust within the div while maintaining its aspect ratio.
This is a snippet of my code:
.box {
width: 640px;
height: 540px;
float: left;
overflow: hidden;
}
.img-border {
width: 100%;
height: 100%;
display: block;
border-radius: 20px;
margin: 5px;
}
<div class="box" id="target">
<div align="center">
<img src="http://cdn.tgdd.vn/Files/2014/06/24/551004/game-duoi-hinh-bat-chu4.jpg" width="60%" height="60%">
</div>
<img class="img-border" id="imgQues" src="https://4.bp.blogspot.com/-K5SwATiq6cI/U84bk7MZPWI/AAAAAAAADkI/4lWV0ErVAFs/s1600/2014-07-22+14.11.00-1.png" />
<div class="comment" id="chatbox">
</div>
</div>
The issue lies in the fact that the .img-border
class is not adjusting properly within the .box
div while also maintaining its aspect ratio.
Is there a way to make the second image, img-border
, fit within the div and retain its original ratio?