Back to the
Component Shop
Read this first! Accordion Alert / Callout Another Lightbox Gallery Audio Player with Playlist Auto Sidebar Backbutton Basic Form Before/After Comparison Buttons Collapsible Alert Contact Form Count-down Script Crossfade Slider CSS Parallax Cut-out Text Decorative Background Details/Summary Classes Drilldown Menu Drop-down Easy Mega Menu Equal Height Columns Filtered Portfolio Flip-cards Glossary Table Hamburger Menu HTML Quiz Horizontal Tabs Image Gallery Image Modal Image Shapes Image Slider with Fade Jquery Parallax Lazy Loading Lightbox Gallery Magnifying Glass Masonry Grid Gallery Mega Menu Modal Optimal Image Sizes Oval Image PHP Includes Range Slider Read More Button Responsive Card Table Responsive Navbar Responsive Shrinknav Responsive Sidebar Responsive Table Round Image Scroll to Top Searchbox Simple Shapes Simple Cards Simple Slider Skill Bars Slide-in Nav Sticky Mega Menu Sticky Vertical Menu Subnav in Dropdowns Tabbed Gallery Tab Navigation Text on Image Translucent Image Translucent Text Layer Vertical Tabs Video Video Scroller Wrapping Text Years Completed Zebra Striped Table

Masonry Grid Gallery

This gallery is made with CSS grid, and we have used a new feature, 'Masonry Grid', which has only been implemented into Firefox at the time of writing this (Feb. 2021). But there is a script that makes it possible to use it in all modern browsers (of course not IE11). You style the grid columns yourself, and then a special styling for the rows the browser will adjust the vertical space between the images. Your images will have the same width, and the code takes care of the height. It's a good idea to try balancing the height of each column, though. That might be a tad fiddly.
The container with the class name 'wrapper-masonry' can be adjusted to regulate the max width of the gallery. If you want it to cover the whole width, the wrapper can be removed and the background colour - if you want a colour - can be moved to the class .grid-masonry.

Download the component.