Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Justify alignment of images in rows (ala Google Images)

I'd like to justify images across a fixed width (exactly how google images does it, eg: here)

Is there a somewhat simple solution for this?

The last resort would be to write a jquery script that calculates how many images it can fit into a row and iterates individually through the images. Seems sort of overkill for something that can be accomplished with text using text-align:justify...

like image 968
miketucker Avatar asked Mar 14 '12 10:03

miketucker


2 Answers

Use display: inline-block; for elements with images and text-align: justify; for parent element. Example:

<ul class="images">
    <li><img src="..."/></li>
    ...
</ul>

and CSS:

.images{text-align: justify;}
.images li{display: inline-block;}
like image 86
Minty Avatar answered Nov 15 '22 14:11

Minty


If you look for a powerful tool to justify images across a fixed width, this jQuery plugin may help you: https://github.com/brunjo/rowGrid.js

Demo

like image 27
Bruno Avatar answered Nov 15 '22 13:11

Bruno