I'm trying to align the elements so that they all line up perfectly without any extra spacing. I've used justify-content: center to center the elements, but they end up looking like this.
However, I want everything to be evenly spaced while still remaining in the center without any additional spaces, similar to this.
One important thing is that when the screen width increases, the elements should not stack in a column but rather remain in a row. Currently, I intentionally reduced the width to prevent them from fitting properly.
.flex {
display: flex;
justify-content: center;
margin-bottom: 24px;
flex-wrap: wrap;
width: 200px;
}
.item {
position: relative;
padding-left: 28px;
display: flex;
}
.item:not(:last-child) {
margin-right: 16px;
}
.item svg {
position: absolute;
top: 5px;
left: 0;
}
.item span {
display: block;
font-size: 16px;
line-height: 1.5;
max-width: 200px;
}
.item img {
width: 30px;
margin-left: 7px;
display: inline-block;
}
<div class="flex">
<div class="item">
<span>Australia <img src="https://i.imgur.com/Ad3jzMI.jpg"></span>
</div>
<div class="item">
<span>Italy <img src="https://i.imgur.com/Ad3jzMI.jpg"></span>
</div>
<div class="item">
<span>Germany <img src="https://i.imgur.com/Ad3jzMI.jpg"></span>
</div>
</div>