My page has space for an image that can be, say, a maximum 100x100 image. Users can upload any image dimension and the web application will resize it, maintaining aspect rat
I know this is and old question already answered but now you can use flex
CSS
.container {
display: flex;
justify-content: center;
align-items: center;
border: 1px solid;
width: 50vw;
height: 50vw;
}
.container img
{
max-width:100%;
max-height:100%;
}
Fiddle Demo
you can also customize the size of your container, some browser may not support flex you can check it here caniuse