Responsive Image Gallery Using HTML and CSS || Coding Power

 


Hello everyone, you can learn how to create a Responsive Image Gallery using HTML and CSS in this blog. So if you want to learn then follow all the steps carefully.  

Watch Full Tutorial on YouTube


Source Code Of Responsive Image Gallery

Step 1: Create Index.html File

Create one file with the name index.html and paste the below code in this file. 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Gallery</title>
</head>
<body>

    <h2>Gallery</h2>
    <div class="gallery">
        <div class="image">
            <img src="images/1.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/2.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/3.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/4.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/5.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/6.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/7.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/8.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/9.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/10.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/11.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/12.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/13.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/14.jpg" alt="">
        </div>
        <div class="image">
            <img src="images/15.jpg" alt="">
        </div>
    </div>
    
</body>
</html>


Step 2: Create style.css File

Create one file with the name style.css and paste the below code in this file.

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
}

h2{
    text-align: center;
    font-size: 30px;
    margin: 15px;
}

.gallery{
    margin: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px,1fr));
    grid-gap: 0.5rem;
    grid-auto-flow: dense;
}

.gallery .image{
    min-height: 150px;
}

.gallery .image img{
    width: 100%;
    height: 200px;
    object-fit: cover;
}


That's It. if you face any error/problem then comment below or Download this code file and then try again. This file is a Zip file so after download you have to extract it.

For Download Code You have to wait 30 seconds.


Post a Comment

Previous Post Next Post