Search code examples
htmlcsssvgcss-positionspacing

How can I have consistent spacing between my images?


I am trying to use CSS to obtain consistent spacing between my images that are listed in the skills section of the HTML code. This is the Code:

.skilllogos {
  height: 100px;
  width: 100px;
}

.jslogo {
  padding-left: 14px;
}
<div class="skill-row">
  <img class="skilllogos" src="images/html.svg" alt="html-icon">
  <img class="skilllogos" src="images/css3.svg" alt="css-icon">
  <img class="skilllogos jslogo" src="images/javascript.svg" alt="javascript-icon">
</div>

Adding the padding to the jslogo does seem to solve the problem (that is how i tried to fix it) but it seems like I'm putting on duck tape to fix the issue and there is probably a better way to do this. If I change the height and width of the images then the spacing will become inconsistent again, it's sort of hard coded and I do not want that. If you haven't guessed already, I am very new to web development so your help is very much appreciated! Thank you!


Solution

  • I think this is what you're looking for

    .skilllogos {
        height: 100px;
        width: auto;
    }
    
    .skilllogos:not(:last-of-type) {
        padding-right: 14px;
    }
    <div class="skill-row">
        <img class="skilllogos" src="images/html.svg" alt="html-icon">
        <img class="skilllogos" src="images/css3.svg" alt="css-icon">
        <img class="skilllogos" src="images/javascript.svg" alt="javascript-icon">
    </div>