Demo

The screen on the right shows a demo of Elastic Columns.
Please note that the plugin does not provide animations or filters, but it is easy to implement it by yourself; all you have to do is to add or remove items from the container, and refresh the grid.

Installation

You can chekout the Git repository or use bower:

bower install elastic-columns

Options

Columns count

$('.container').elasticColumns({columns: 3});

You probably want to set a number of colums to use. The value may be changed later using the plugin API.

Margins

$('.container').elasticColumns( { innerMargin: 10, // the gap between two tiles outerMargin: 20 // the gap between the tiles and the edge of the container });

You can tell the plugin to use margins if you don't want to set them yourself in your CSS styles.

API

The plugin provides a very simple API.
Actually, you will only need a few things:

Refreshing the layout

$('.container').elasticColumns('refresh');

You may want to refresh the layout when the user resizes the window, or when you add new items to the grid.
To insert new content, you may just append it to your container; the plugin will handle it.
If you append pictures, be sure to wait them to be loaded before refreshing the layout, or the calculations may be false.

Modifying settings on the fly

$('.container').elasticColumns('set', 'columns', 4);

What if you are building a responsive website ?
You may want to change the number of columns depending on the container width.
When you are updating a parameter, don't forget to refresh the grid.

Destroying the layout

$('.container').elasticColumns('destroy');

If you want to restore the layout to its initial state.

Ignoring items

If may add theelastic-columns-ignoreclass to some items if you don't want them to be positionned on the grid.
This can be useful if you are filtering the grid content and don't want to remove items on the fly.

适用浏览器:360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. 不支持IE8及以下浏览器。

来源:懒人素材

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae lorem eget eros dictum varius.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae lorem eget eros dictum varius. Donec tortor purus, convallis ut dapibus cursus, fringilla eleifend libero. Vestibulum accumsan enim non lectus aliquam, eget accumsan nibh sollicitudin.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae lorem eget eros dictum varius. Donec tortor purus, convallis ut dapibus cursus, fringilla eleifend libero. Vestibulum accumsan enim non lectus aliquam, eget accumsan nibh sollicitudin.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae lorem eget eros dictum varius. Donec tortor purus, convallis ut dapibus cursus, fringilla eleifend libero. Vestibulum accumsan enim non lectus aliquam, eget accumsan nibh sollicitudin. Donec tortor purus, convallis ut dapibus cursus, fringilla eleifend libero. Vestibulum accumsan enim non lectus aliquam, eget accumsan nibh sollicitudin.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae lorem eget eros dictum varius.

Lorem ipsum dolor

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae lorem eget eros dictum varius. Donec tortor purus, convallis ut dapibus cursus, fringilla eleifend libero. Vestibulum accumsan enim non lectus aliquam, eget accumsan nibh sollicitudin.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae lorem eget eros dictum varius. Donec tortor purus, convallis ut dapibus cursus, fringilla eleifend libero. Vestibulum accumsan enim non lectus aliquam, eget accumsan nibh sollicitudin.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae lorem eget eros dictum varius. Donec tortor purus, convallis ut dapibus cursus, fringilla eleifend libero. Vestibulum accumsan enim non lectus aliquam, eget accumsan nibh sollicitudin. Donec tortor purus, convallis ut dapibus cursus, fringilla eleifend libero. Vestibulum accumsan enim non lectus aliquam, eget accumsan nibh sollicitudin.