Masonry is a JavaScript library for arranging elements of varying heights into a grid without vertical gaps. It serves as a DOM element positioner and dynamic layout manager that calculates and applies absolute coordinates to HTML elements based on available vertical space.
The system functions as a responsive grid engine using percentage-based widths to maintain consistent structures across different screen sizes. It includes capabilities to recalculate grid positions after images load or browser windows resize to prevent element overlap.
The library covers grid management and positioning, including the ability to reserve static space and preserve horizontal order. It also provides layout transition utilities for moving items into place using staggered animations and event listeners to trigger functions during layout changes.