• Home
  • PHP
  • MySQL
  • Laravel
  • Demos
  • HTML
  • jQuery
  • Framework
  • Request Tutorial
PHP Lift
  • Home
  • Demos
  • Advertisement
PHP Lift
  • Home
  • PHP
  • MySQL
  • Laravel
  • Demos
  • HTML
  • jQuery
  • Framework
  • Request Tutorial
  • Follow
    • Facebook
    • Twitter
    • Google+
    • Pinterest
    • Youtube
    • Instagram
    • RSS
How to create Full Screen Responsive Image Gallery using CSS and Masonry
Home
CSS

How to create Full Screen Responsive Image Gallery using CSS and Masonry

July 30th, 2025 Huzoor Bux CSS, jQuery 1 comments

Facebook Twitter Google+ LinkedIn Pinterest

How to create a full-screen responsive image gallery using CSS and Masonry ( is a JavaScript grid layout library ), Masonry gallery is a popular grid layout that uses optimal space to place images without the need to crop your pictures. We are giving you this tutorial with a nice demo and source to download for free.

 

DEMO
DOWNLOAD CODE

 

Step 1:

Create a grid and add images with different sizes.

<div id="container">

    <div class="grid-sizer"></div>

    <div class="item">

        <img src="http://placekitten.com/650/450" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/650/750" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/1650/1250" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/850/450" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/900/700" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/700/1400" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/1200/1300" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/750/650" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/1600/900" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/700/400" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/1100/1200" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/800/1100" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/600/400" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/1100/900" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/1320/1200" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

    <div class="item">

        <img src="http://placekitten.com/1024/768" class="image">

        <a class="onhandover" href="#">

            <h3 class="title">Your Image Title</h3>

            <div class="description">

                <p>

                    Description Goes here!!

                </p>

            </div>

        </a>

    </div>

</div>

The above markup creates an image grid with title and description with images placeholder for fast images delivery http://placekitten.com/1024/768 placekitten.com is A quick and simple service for getting pictures of kittens for use as placeholders in your designs or code.

CSS to organize your gallery:

<style>

.item {

    float: left;

    position: relative;

    line-height: 1em;

}



.grid-sizer { width: 20%; }

.item { width: 20%; }



@media screen and (max-width: 1224px) {

  /* 10 columns for larger screens */

  .grid-sizer { width: 33.33%; }

  .item { width: 33.33%; }

}



@media screen and (max-width: 720px) {

  /* 10 columns for larger screens */

  .grid-sizer { width: 50%; }

  .item { width: 50%; }

}



@media screen and (max-width: 480px) {

  /* 10 columns for larger screens */

  .grid-sizer { width: 100%; }

  .item { width: 100%; }

}



.image{

    max-width: 100%;

    margin: 0;

    display: block;

}



.image:after {

    clear:both;

}



.onhandover {

    width: 100%;

    height: 100%;

    background-color: rgba(0,0,0,0.5);

    position: absolute;

    top: 0;

    left: 0;

    text-decoration: none;

    color: #fff;

    display: none;

}



.onhandover .title {

    text-align: center;

    font-size: 30px;

}



.onhandover .description {

    position: absolute;

    bottom: 0;

    left: 0;

    background-color: rgba(0,0,0,0.80);

    width: 100%;

    margin: 0;

}



.onhandover .description p {

    text-align: center;

}



.item:hover .onhandover {

    display: block;

}

.item h3 {

    margin: 20px;

}

.item p {

    margin: 10px;

}

</style>

We used @media for different screens to make the gallery responsive and .onhandover class to show the title and description oh the handover event.

jQuery files to Include:

<script type="text/javascript" src="jquery-1.8.0.min.js"></script>

<script type="text/javascript" src="masonry.pkgd.min.js"></script>

Initialize Masonry using the following:

<script type="text/javascript">

$(window).load( function() {



    $("#container").masonry({

        "itemSelector": ".item",

        "columnWidth": ".grid-sizer",

    });



});

</script>

That’s all for today’s tutorial. I hope you like this tutorial. Please don’t forget to give us your feedback and share it with your friends.

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook

Related

  • Tags
  • css
  • Full Screen
  • How to
  • Masonry
  • Responsive Image Gallery
Facebook Twitter Google+ LinkedIn Pinterest
Next article Is PHP dead or still has a chance for Web Development?
Previous article A Complete Guide to Full-Stack Development

Huzoor Bux

I am a PHP Developer

Related Posts

Create fly to cart / basket effect for eCommerce using jQuery and CSS CSS
August 4th, 2025

Create fly to cart / basket effect for eCommerce using jQuery and CSS

How to integrate jQuery FullCalendar with PHP & MySQL Example Bootstrap
August 4th, 2025

How to integrate jQuery FullCalendar with PHP & MySQL Example

Skeleton Screen Loading Animation using HTML and CSS CSS
August 4th, 2025

Skeleton Screen Loading Animation using HTML and CSS

1 Comments

  1. How to Create Full Screen Responsive Image Gallery Using CSS and Masonry – A2M1N
    October 8, 2020 at 8:27 am Reply ↓

    […] Article URL: https://www.phplift.net/how-to-create-full-screen-responsive-image-gallery-using-css-and-masonry/ […]

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe
Get new posts by email:
Powered by follow.it
Advertisement
Like us
Recent Posts
  • Laboratory Management System (LIMS) in PHP MySQL – A Complete Guide
  • Cool New JavaScript Features
  • WhatsApp chatbot in Python using Dialogflow.com
  • Cool CSS3 features
  • PHP Contact Form with Google reCAPTCHA V3 Example
Categories
  • API
  • Bootstrap
  • Bot
  • CSS
  • CSS 3
  • Database
  • Designing
  • Framework
  • Guide
  • HTML
  • HTML 5
  • JavaScript
  • jQuery
  • Laravel
  • MySQL
  • Node.js
  • oAuth
  • Payment
  • PHP
  • Python
  • Social
  • Tips
  • Web 3.0
  • WordPress
Weekly Tags
  • PHP
  • javascript
  • How to
  • laravel
  • css
  • HTML to PDF
  • jQuery
  • api
  • Web Development
  • MYSQL
  • About
  • Privacy Policy
  • Back to top
© PHPLift.net. All rights reserved.