0

In this moment, the image in the div element uses flex, and some CSS to sale them into a box of some sort. Meanwhile the problem seem to be when I want to center the images to the center of the CSS box.

I tried to do it with text-align: center and also with margins, but that makes the anchor elements closer to one another. What I want is to keep the distance between the a links while the images are centered to to center of the box.

What i see right now:

initial

as you see in the last two boxes the images are aligned to the top left, and not to the center.

What i want to achieve (dots are the image):

the expected result

.image-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-left: auto;
  margin-right: auto;
  align-items: center;
  margin-top: 20px;
  padding-left: 80px;
}

.image-list img {
  width: 50px;
  height: 50px;
  margin-right: 10px;
  margin-bottom: 10px;
  object-fit: contain;
  justify-content: center;
}
<div class="image-list">
  <a href=""><img src="https://via.placeholder.com/80" alt=""></a>
  <a href=""><img src="https://via.placeholder.com/80" alt=""></a>
  <a href=""><img src="https://via.placeholder.com/80" alt=""></a>
  <a href=""><img src="https://via.placeholder.com/80" alt=""></a>
  <a href=""><img src="https://via.placeholder.com/80" alt=""></a>
  <a href=""><img src="https://via.placeholder.com/80" alt=""></a>
</div>
isherwood
  • 58,414
  • 16
  • 114
  • 157

1 Answers1

1

target the .image-list and display flex along with other desired attribute like so;

.image-list a {
    display:flex;
    justify-content: center;
    align-items:center;
    }

You will also want to use flex-direction:column; on the .image-list

SeanMarc
  • 139
  • 8