N
N
Nikita Shchypylov2018-03-04 13:11:42
css
Nikita Shchypylov, 2018-03-04 13:11:42

How can you crop a photo with CSS?

Hello everyone
There are photos, 600x400 (20 pieces). I need to make them round, that is border-radius: 50%. But, since it is not square, it looks bad. I can cut all of them with my hands in FS up to 400x400, but 20 pieces are so-so fun to click. Is there a solution with CSS?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alvvi, 2018-03-04
@alvvi

It is difficult to answer the question, since there are several solutions and they depend on the situation, but for example, you can try this:

.img {
   width: 400px;
   height: 400px; 
   object-fit: cover;
   object-position: center;
}

If you don't like object-fit support, you can achieve a similar effect using wrapping and overflow:hidden and transforms / positioning.
.wrapper {
  width: 400px;
  height: 400px;
  border-radius: 50%;
  overflow: hidden;
}
.img {
  transform: translateX(-100px); 
}

Well, there is also an option to make them using background-image.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question