Complex Masonry Layout Using Pure CSS

Complex masonry is a sensitive, fluid, masonry layout built using a CSS grid layout system. The purpose of providing a quick way to implement Pinterest-like grid layouts on modern web apps using pure CSS / CSS3.

Minimalist Dependency-Free Masonry Layout Library | MiniMasonry.js

How to make use of it:

1. The primary HTML structure for the masonry format.

<section class="masonry">
  <div class="masonry-item cell cell-1">
    // Add Image Here
  </div>
  <div class="masonry-item cell cell-2">
    // Add Image Here
  </div>
  <div class="masonry-item cell cell-3">
    // Add Image Here
  </div>
  <div class="masonry-item cell cell-4">
    // Add Image Here
  </div>
  <div class="masonry-item cell cell-5">
    // Add Image Here
  </div>
  <div class="masonry-item cell cell-6">
    // Add Image Here
  </div>
  <div class="masonry-item cell cell-7">
    // Add Image Here
  </div>
  <div class="masonry-item cell cell-8">
    // Add Image Here
  </div>  
  </div>
</section>

2. The main CSS types for the masonry format.

.masonry {
  background-color: #000324;
  width: 100%;
  height: 100vh;
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(14, 1fr);
  row-gap: 1rem;
  column-gap: 1rem;
}

.cell-1 {
  grid-column: 1 / 6;
  grid-row: 1 / 6;
}


.cell-2 {
  grid-column: 6 / 9;
  grid-row: 1 / 11;
}

.cell-3 {
  grid-column: 9 / 12;
  grid-row: 1 / 4;
}

.cell-4 {
  grid-column: 12 / -1;
  grid-row: 1 / 4;
}

.cell-5 {
  grid-column: 1 / 4;
  grid-row: 6 / 11;
}

.cell-6 {
  grid-column: 4 / 6;
  grid-row: 6 / 7;
}

.cell-7 {
  grid-column: 4 / 6;
  grid-row: 7 / 11;
}

.cell-8 {
  grid-column: 1 / 6;
  grid-row: 11 / -1;
}

3. Make the format absolutely responsive.

/* Responsive */
/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
  .masonry {
    background-color: white;
    width: 100%;
    height: 100vh;
    padding: 1rem;
    display: flex;
    flex-flow: column;
  }
}

4. Auto resize the picture to suit the grid item.

img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
  pointer-events: none;
}

Fluid Masonry Layout Using CSS Grid, Complex Masonry Plugin/Github

Masonry-Layout-Demo


See Demo And Download

Official Website(alnahian2003): Click Here

This superior jQuery/javascript plugin is developed by alnahian2003. For extra Advanced Usages, please go to the official website.

Related Posts

Cookie-Consent-Using-Bootstrap

How to Create a Simple Cookie Banner Consent Using Bootstrap 4

Cookie Consent Popup Javascript – Quick and simple tutorial for creating a simple Bootstrap cookie banner. If you have a website or blog with people visiting or…

Create-HTML-Terminals

Create Custom HTML Terminals With Pure JavaScript | shell.js

Custom HTML Terminals is A JavaScript library to create HTML terminals on web pages. The shell js JavaScript library offers a straightforward method to create Ubuntu, OS X,…

Bootstrap-Alert-Bootbox

Bootstrap Alert, Confirm, and Flexible Dialog Boxes | Bootbox

Bootbox.js is a small JavaScript library that allows you to create programming dialogs using Bootstrap templates, without having to worry about creating, managing, or removing any required…

Slider-fg-carousel

An Accessible Touch-enabled Slider Web Component | fg-carousel

fg-carousel Slider – A simple & modern slider web component to create versatile, accessible, touch-enabled picture carousels utilizing CSS scroll snap, Custom Element, and Intersection Observer API….

Tags-Input-Component

A Lightweight and Efficient Tags Input Component in Vanilla JS | tagify

tagify transforms an input field or textarea into a tags component, in an easy and customizable way, with great performance and a small code footprint, full of…

copy-to-clipboard-javascript

A Lightweight Library to Copy Text to Clipboard | CopyJS

CopyJS is a lightweight JavaScript library that allows you to copy plain text or HTML content to the clipboard. Must Read: Tiny Library for Copy Text In…