Answer the question
In order to leave comments, you need to log in
How to implement scale with maintaining proportions in css?
There is an image that is placed in a container and which needs to be scaled while maintaining proportions and centered if necessary.
I know how to do it in js. But before doing this, I wanted to know if the same thing can be done in the css language, which should have such capabilities at the native level. Is it possible and if so, how?
Answer the question
In order to leave comments, you need to log in
An image for the background and background-size:cover;
Or prescribe width or height, if something is one, then the second according to the proportions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question