I have code like this:
<style>
table {
width: 20%;
border: 1px solid black;
}
.player_line {
display: flex;
align-items: center;
}
.player_left,
.player_right {
flex: 1;
border: 1px solid red;
}
.player_avatar {
border-radius: 50%;
width: 40px;
height: 40px;
margin-right: 5px;
margin-top: 5px;
margin-bottom: 5px;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
</style>
<table>
<tr>
<td>
<div class="player_line">
<div class="player_left"></div>
<div class="player_avatar" style="background-image: url(./assets/static/images/user.png)"></div>
A long user name
<div class="player_right"></div>
</div>
</td>
</tr>
<tr>
<td>
<div class="player_line">
<div class="player_left"></div>
<div class="player_avatar" style="background-image: url(./assets/static/images/user.png)"></div>
Not long name
<div class="player_right"></div>
</div>
</td>
</tr>
<tr>
<td>
<div class="player_line">
<div class="player_left"></div>
<div class="player_avatar" style="background-image: url(./assets/static/images/user.png)"></div>
A super long name
<div class="player_right"></div>
</div>
</td>
</tr>
</table>
This will look like:
What I can do, to align the avatars, so they are always aligned to left, but the whole player info (avatar + name) is still center in the td element? Like so:
I think that, the important thing here is that the player info can grow as it please (if there is space), so the avatar and name of the player always look correct (e.g. the name is always in one line, and the picture is not down scaled).