So I have an img
box, and the user can drop an image on it. The CSS currently ensure whatever the images original size is it will be displayed as a 300x300 image using this CSS
So an image of 200x200 would be increased to fit exactly and an image 400x400 would be decreased to fit exactly in the 300x300 img element.
.largeartwork img {
max-width:300px;
max-height:300px;
min-width:300px;
min-height:300px;
border: 3px solid black;
}
This works correctly, but what I want to do for non square images is fill the space as best as possible but preserve the aspect ratio
For example an image of 300x200 (300 pixels wide, 200 pixels height)should only fill the width up but not the height, the same with an image of 600x400 etcetera.
Note on possible duplicate The answers on linked post are outdated and not as good