A
A
Alexey2015-11-20 15:51:54
css
Alexey, 2015-11-20 15:51:54

How to stretch an image to full width and height?

Hey! This is how I center images by height jsfiddle.net/30gngdw0/. those. the image has the width of the parent container, but if it is higher than its height, then it is centered, and the edges of the image are hidden behind the edges of the container (for example, picture 1 ).
The question is what to do if an image appears in the same container that is smaller than the height of the container (for example, picture 2 )? Is it possible to center the image both vertically (already done) and horizontally so that the images occupy the entire area of ​​the container, regardless of the length or width? Keeping the proportions of the picture is a must!
In fact, picture 2 in pixels is still larger in height than the container

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Minningt, 2015-11-20
@Minningt

jsfiddle.net/30gngdw0/2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question