Oh boy, I think I found a good solution with minimal CSS and no JS. Check it out:
img {width:100%;}_x000D_
li {_x000D_
display: inline-block;_x000D_
width:8em;_x000D_
list-style:none;_x000D_
}_x000D_
ul {text-align: justify;}
_x000D_
<ul>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li>_x000D_
<img src="http://www.planwallpaper.com/static/images/kitty-cat.jpg" />_x000D_
</li>_x000D_
<li></li>_x000D_
<li></li>_x000D_
<li></li>_x000D_
<li></li>_x000D_
<li></li>_x000D_
<li></li>_x000D_
<li></li>_x000D_
</ul>
_x000D_
The key here is to remember that what we are trying to achieve is exactly what text-align: justify
does!
The empty elements in the HTML are there to make the last row display perfectly without changing the appearance, but might not be needed given what you are trying to achieve. For perfect balance in every situation, you need at least x-4 empty elements, x being the number of elements to display, or n-2, n being the number of column you want to display.