Horizontally spacing a row of images evenly

Posted by Tesla on Stack Overflow See other posts from Stack Overflow or by Tesla
Published on 2012-10-11T05:32:12Z Indexed on 2012/10/11 9:37 UTC
Read the original article Hit count: 133

Filed under:
|

I have a few rows of images like so

<div class="row">
  <img src="image.jpg" alt="">
  <img src="image.jpg" alt="">
  <img src="image.jpg" alt="">
  <img src="image.jpg" alt="">
  <img src="image.jpg" alt="">
</div>

Each image has a different width, and there is also a different number of images on each row (4-6). I want to space the images evenly in the row, the row has a fixed width of 960px.

I could do this by calculating the total empty space for each row and then dividing it among the images for a margin, but I was hoping there was something simpler that I could apply to every row instead of having to calculate and code a separate one for each row.

© Stack Overflow or respective owner

Related posts about html

Related posts about css