私はgridify.jsロジックを調べることでこれに対する解決策を見つけました。ここに私のコードです:
var items = options.items;
var width = options.containerWidth,
item_margin = parseInt(options.margin || 0),
item_width = parseInt(options.max_width || options.width || 220),
column_count = Math.max(Math.floor(width/(item_width + item_margin)), 1),
left = column_count == 1 ? item_margin/2 : (width % (item_width + item_margin))/2,
lastHeight = 0;
if (options.max_width) {
column_count = Math.ceil(width/(item_width + item_margin));
item_width = (width - column_count * item_margin - item_margin)/column_count;
left = item_margin/2;
}
for (var i = 0, length = items.length; i < length; i++) {
var ratio = item_width/items[i].width;
items[i].width = item_width;
items[i].height = items[i].height * ratio;
items[i].position.y = lastHeight + item_margin/2;
items[i].position.x = 0;
lastHeight += items[i].height + (item_margin * 2);
}
上記の機能にパラメータを渡してください。コンテナ内のイメージ/コンテンツをグリッド化します。コンテナごとに単一の列を使用しましたが、gridify.jsの元のコードを使用して複数の列を使用できます