<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Flexbox Gallery with Media Query</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }

        .gallery {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-around;
            margin: 20px auto;
        }

        .gallery-item {
            flex: 0 0 calc(33.33% - 20px);
            margin: 10px;
            overflow: hidden;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }

        .gallery-item:hover {
            transform: translateY(-5px);
        }

        .gallery-item img {
            width: 100%;
            height: auto;
            border-radius: 8px 8px 0 0;
        }

        @media (max-width: 768px) {
            .gallery-item {
                flex: 0 0 calc(50% - 20px);
            }
        }

        @media (max-width: 480px) {
            .gallery-item {
                flex: 0 0 calc(100% - 20px);
            }
        }
    </style>
</head>
<body>

    <div class="gallery">
        <div class="gallery-item">
            <img src="https://placekitten.com/300/200" alt="Cat 1">
        </div>
        <div class="gallery-item">
            <img src="https://placekitten.com/301/200" alt="Cat 2">
        </div>
        <div class="gallery-item">
            <img src="https://placekitten.com/302/200" alt="Cat 3">
        </div>
        <div class="gallery-item">
            <img src="https://placekitten.com/303/200" alt="Cat 4">
        </div>
        <div class="gallery-item">
            <img src="https://placekitten.com/304/200" alt="Cat 5">
        </div>
        <div class="gallery-item">
            <img src="https://placekitten.com/305/200" alt="Cat 6">
        </div>
        <!-- Add more gallery items as needed -->
    </div>

</body>
</html>

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.