R
R
Rinat2018-02-06 07:58:03
css
Rinat, 2018-02-06 07:58:03

How to align horizontal and vertical photos without distortion?

Guys, tell me with an example how to implement such an alignment,
5a7934f326b19538463739.png
i.e. horizontal and vertical photos adjust to the required size without distorting the photo.
Thanks to !!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Froggyweb, 2018-02-06
@Froggyweb

object fit
https://github.com/bfred-it/object-fit-images

A
Anatoly Zharov, 2018-02-06
@SeaBreeze876

for an element, padding as a percentage will be calculated from the width of the element, c background-size: cover the background image will completely fill the element

.image {
    width: 100px;
    height: 0;
    padding-top: 60%;
    background-image: url(url-to-image);
    background-size: cover;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question