Answer the question
In order to leave comments, you need to log in
How to scale an image to fit max-width and max-height while maintaining aspect ratio?
Hello, there is a task to increase the image to the specified max-width or max-height while maintaining the proportions. For example:
img {
display: block;
max-width: 400px;
max-height: 200px;
}
<img src="https://loremflickr.com/800/100">
<img src="https://loremflickr.com/100/150">
width: 100%; height: auto;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question