I need help with an <img>
element that is absolutely positioned inside a <div>
element. The <div>
has dimensions of 100px by 100px.
When the <img>
is clicked, it should expand to a maximum width or height of 500px by 700px. If the original size of the <img>
is smaller, for example 300px by 250px, then it should not exceed that size. Importantly, the aspect ratio must be maintained.
Simply setting the height and width to 100% results in the <img>
matching the size of its containing <div>
.
I am seeking a solution using either CSS or vanilla JavaScript. (I do not need code for a click animation, just a static final result so I can understand the concept)