D
D
Denis Bukreev2016-10-08 09:10:37
css
Denis Bukreev, 2016-10-08 09:10:37

How to set the maximum width and height of an image in CSS while maintaining aspect ratio?

So it goes.
It is necessary to somehow prohibit the image from changing its proportions, but how?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nicholas, 2016-10-08
@ACCNCC

masscode.ru/index.php/k2/item/45-lifullsize

Z
Zhainar, 2016-10-08
@zhainar

img{
max-height: 200px;
max-width: 200px;
heigth: auto;
width: auto;
}

P
Philip Gaponenko, 2016-10-09
@filgaponenko

background-size: cover;
https://jsfiddle.net/psr1919plus21/5khsp9qt/1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question