V
V
vasIvas2015-10-10 19:03:55
css
vasIvas, 2015-10-10 19:03:55

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.
71acedb909614c159a68aad5d3ae6abc.png
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

2 answer(s)
M
Maxim Timofeev, 2015-10-10
@vasIvas

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.

I
Ivan Drozhzhin, 2015-10-11
@RotarYMonkeY

Maybe so?
background: url(/img.png) top center;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question