body {
    margin: 0;
    padding: 0;
}

h1 {
    text-align: center;
    margin-top: 20px;
}

.gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 20px;
    margin: 0 auto;
}

.gallery-item {
    width: 23%;
    /* 每排4张图片 */
    margin: 1%;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(0.9);
}

.gallery-item .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    text-align: center;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gallery-item:hover .overlay {
    transform: translateY(0);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .gallery-item {
        width: 48%;
        /* 每排2张图片 */
        margin: 1%;
    }
}

@media (max-width: 480px) {
    .gallery-item {
        width: 98%;
        /* 每排1张图片 */
        margin: 1%;
    }
}