Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

miromanestar/jQuery-Horizontal-Masonry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery-Horizontal-Masonry

An example of a horizontal masonry layout using jQuery!

This example utilizes jQuery to make things easier, but everything here can also be done quite easily in vanilla JS!

Live demo here!

Essentially allows CSS to find the expected height of the items in a vertical masonry layout, sets that height (Plus an additional buffer to accomodate discrepancies) to the container, and applies some CSS flex rules depending on the window/screen size, including the flexbox order property.

That way, the JS is extremely lightweight and doesn't need to perform nearly as many calculations as traditional horizontal masonry layout solutions.

Support up to three columns. By default, it will organize the divs into 3 columns, and scale down as the screen shrinks. This will need to be modified in both the CSS and JS files to accomodate additional column sizes.

Some of the CSS critical to this solution came from this guide here.