鼠标悬停图片遮罩动画

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鼠标悬停图片遮罩动画</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Arial', sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: #f5f5f5;
            padding: 20px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            text-align: center;
        }
        
        h1 {
            margin-bottom: 30px;
            color: #333;
        }
        
        .image-gallery {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 20px;
        }
        
        .image-container {
            position: relative;
            width: 300px;
            height: 200px;
            overflow: hidden;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }
        
        .image-container:hover {
            transform: translateY(-5px);
        }
        
        .image-container img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease;
        }
        
        .image-container:hover img {
            transform: scale(1.1);
        }
        
        .image-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            color: white;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            opacity: 0;
            transition: opacity 0.5s ease;
            padding: 20px;
        }
        
        .image-container:hover .image-overlay {
            opacity: 1;
        }
        
        .image-overlay h3 {
            font-size: 1.5rem;
            margin-bottom: 10px;
            transform: translateY(20px);
            transition: transform 0.5s ease;
        }
        
        .image-overlay p {
            font-size: 1rem;
            margin-bottom: 15px;
            transform: translateY(20px);
            transition: transform 0.5s ease 0.1s;
        }
        
        .image-overlay a {
            display: inline-block;
            padding: 8px 16px;
            background: #fff;
            color: #333;
            text-decoration: none;
            border-radius: 4px;
            transform: translateY(20px);
            transition: all 0.5s ease 0.2s;
        }
        
        .image-container:hover .image-overlay h3,
        .image-container:hover .image-overlay p,
        .image-container:hover .image-overlay a {
            transform: translateY(0);
        }
        
        .image-overlay a:hover {
            background: #333;
            color: #fff;
        }
        
        .footer {
            margin-top: 50px;
            color: #666;
            font-size: 0.9rem;
        }
        
        .footer a {
            color: #333;
            text-decoration: none;
        }
        
        .footer a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>图片悬停遮罩效果</h1>
        
        <div class="image-gallery">
            <!-- 图片1 -->
            <div class="image-container">
                <img src="https://source.unsplash.com/random/600x400?nature" alt="自然风景">
                <div class="image-overlay">
                    <h3>自然之美</h3>
                    <p>探索大自然的奇妙景观和壮丽风光</p>
                    <a href="#">查看详情</a>
                </div>
            </div>
            
            <!-- 图片2 -->
            <div class="image-container">
                <img src="https://source.unsplash.com/random/600x400?city" alt="城市风光">
                <div class="image-overlay">
                    <h3>城市风光</h3>
                    <p>现代都市的繁华与建筑的魅力</p>
                    <a href="#">查看详情</a>
                </div>
            </div>
            
            <!-- 图片3 -->
            <div class="image-container">
                <img src="https://source.unsplash.com/random/600x400?animal" alt="动物世界">
                <div class="image-overlay">
                    <h3>动物世界</h3>
                    <p>野生动物精彩瞬间的捕捉</p>
                    <a href="#">查看详情</a>
                </div>
            </div>
        </div>
        
        <div class="footer">
        </div>
    </div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值