I have a dynamically generated list of planets. Following detection of some of the properties of these planets via knockout.js, one or two icons may be added to them to indicate certain features. The icons are a green circle and a blue thruster.
When either icon is added to a planet, it looks fine, but if both icons are added the thruster is misaligned.
<div class="all-planets" data-bind="foreach: selection.system().planets()">
<div
class="div_planet"
data-placement="right"
data-bind="tooltip: $root.gwaioPlanetData[$index()]"
>
<img
style="height: 20px; width: 20px"
data-bind="attr: { src: 'coui://ui/main/shared/img/planets/' + $data.generator.biome + '.png' }"
/>
<img
data-bind="visible: $data.starting_planet"
class="img_start"
src="coui://ui/main/game/live_game/img/planet_list_panel/icon_planet_start.png"
/>
<img
data-bind="visible: $data.required_thrust_to_move > 0"
class="thruster_count"
src="coui://ui/main/game/server_browser/img/icon_thruster.png"
/>
</div>
</div>
#system-detail .all-planets {
margin: 0px 0px 0px 0px;
padding: 0px 16px 0px 4px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
#system-detail .div_planet {
height: 20px;
width: 20px;
margin: 4px;
}
#system-detail img.img_start {
height: 16px;
width: 16px;
position: relative;
top: -12px;
right: -10px;
}
#system-detail .thruster_count {
height: 12px;
width: 13px;
position: relative;
top: -8px;
}
I fear this is simply my lack of knowledge in CSS showing. I've found I can align the thrusters if I add <div> tags around both <img> tags and then set an absolute position for the thruster image. However, the planets can potentially wrap around and form a second row, which would break this setup. It also makes the setup incredibly fragile since this area could be subject to change.
What should I be doing to prevent the green circle image disrupting the position of the blue thruster image?
EDIT: I've added the icons (all planet dimensions are the same)





I took advantage of knockout to setup two different classes, determining which to use based on whether both icons were present. This allows me to setup two different CSS class selectors.