Answer the question
In order to leave comments, you need to log in
How to make a responsive image?
Good afternoon! Can you please tell me how to make the image have a certain width and height, but not more than 100%?
It is not difficult to do this, however, you need to somehow report the width / height, otherwise the picture becomes stretched.
Example: https://jsfiddle.net/5fs3dkqj/
How can I decide? Preferably without JS, but you can use it too :) The size of the original image is there.
PS: This question arose due to the fact that when the site is loaded (as well as when changing the image), everything jumps, since the picture does not know its height. And if you set the height, then it becomes stretched.
Answer the question
In order to leave comments, you need to log in
Сделайте обертку, туда передавайте нужные размеры (https://jsfiddle.net/5fs3dkqj/2/)
img {width: 100%; max-width: 100%; height: auto;}
если не нужно на всю ширину, то width: 100% уберите
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question