Skip to main content
All CollectionsTroubleshooting and FAQsFrequently Asked QuestionsBlog Module
How to Make a Masonry Blog Layout Using the Isotope JS Library
How to Make a Masonry Blog Layout Using the Isotope JS Library

Learn how to create a dynamic masonry blog layout using the Isotope JS library for a visually appealing and organized blog section.

Updated over 4 months ago

Creating a visually appealing and organized blog layout can greatly enhance the user experience on your website.

A masonry layout arranges your blog posts in a dynamic grid, optimizing space and improving readability. Using the Isotope JS library, you can effortlessly achieve this stylish and functional design.

This article will guide you through the steps to implement a masonry blog layout using the Isotope JS library, helping you create a captivating and well-organized blog section.

For this customization to work properly, we need to use the Blog module with the Fullwidth layout. The Grid will be created using the Isotope JS library.

  1. Add the Blog module to the Page

  2. Open the Blog module's settings and go to Design Tab → Layout

  3. Choose Fullwidth

    Blog module's layout

  4. In Advanced Tab → CSS ID & Classes → CSS Class, type in divi_isotope_blog

    Blog module CSS class

  5. In the Blog module's Advanced Tab Custom CSS Free Form CSS, add this CSS code:

    selector .et_pb_post {
    width: calc((100% / 3) - 20px);
    margin-bottom: 20px;
    border: 1px solid #d8d8d8;
    padding: 20px;
    }

    selector .et_pb_post .entry-featured-image-url {
    margin: -20px -20px 30px -20px;
    }

    @media (max-width: 980px) and (min-width: 768px) {
    selector .et_pb_post {
    width: calc((100% / 2) - 20px);
    }
    }

    @media (max-width: 767px) {
    selector .et_pb_post {
    width: calc(100% - 20px);
    }
    }

  6. In Divi → Theme Option → Integration tab > Header, add this Js Code:

    <script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
    <script id="masonry-blog-layout">
    (function ($) {
    $(document).ready(function () {
    var gutter = Number($('.divi_isotope_blog').css('--space-between-each-post').replace('px', ''));
    function initIsotope() {
    var $container = $('.divi_isotope_blog .et_pb_ajax_pagination_container');
    // Check if Isotope has already been initialized
    if (!$container.data('isotope-initialized')) {
    $container.isotope({
    itemSelector: '.divi_isotope_blog .et_pb_post',
    percentPosition: true,
    masonry: {
    gutter: gutter,
    columnWidth: '.divi_isotope_blog .et_pb_post'
    },
    });
    // Set a flag to indicate that Isotope has been initialized
    $container.data('isotope-initialized', true);
    } else {
    // If already initialized, just reload Isotope
    $container.isotope('layout');
    }
    var wrapperHeight = $container.css('height');
    $('.et_pb_ajax_pagination_container > div').css({ 'top': wrapperHeight, 'position': 'relative' });
    }
    initIsotope();
    $(document).ajaxComplete(function () {
    setTimeout(initIsotope, 250);
    });
    });
    })(jQuery);
    </script>

The result of the above CSS and JS code can be seen in the GIF below:

Blog module using Isotope library to create a custom Mansonry layout
Did this answer your question?