When I apply a margin-right of 10px to the first and second child elements, and 0px to the third child element, the third child jumps to a new line.
I can see that the double 10px margin-right is the issue here, but I'm not sure how to fix it.
.albums-container {
font-size: 0px;
margin-top: 10px;
}
.albums-container-element {
display: inline-block;
margin: 0 10px 10px 0;
width: 33.33333%;
}
.albums-container-element:nth-child(3n+3) {
margin-right: 0;
}
.centeredImage {
width: 100%;
height: 100%;
}
<div class="albums-container">
<div class="albums-container-element">
<img class='centeredImage' src='https://www.thesprucepets.com/thmb/4j55UCCc_TyTHtgwflSG8TeGpBU=/960x0/filters:no_upscale():max_bytes(150000):strip_icc()/kitten-looking-at-camera-521981437-57d840213df78c583374be3b.jpg'>
</div>
<div class="albums-container-element">
<img class='centeredImage' src='https://www.thesprucepets.com/thmb/4j55UCCc_TyTHtgwflSG8TeGpBU=/960x0/filters:no_upscale():max_bytes(150000):strip_icc()/kitten-looking-at-camera-521981437-57d840213df78c583374be3b.jpg'>
</div>
<div class="albums-container-element">
<img class='centeredImage' src='https://www.thesprucepets.com/thmb/4j55UCCc_TyTHtgwflSG8TeGpBU=/960x0/filters:no_upscale():max_bytes(150000):strip_icc()/kitten-looking-at-camera-521981437-57d840213df78c583374be3b.jpg'>
</div>
</div>