CSS3鼠标经过动画显示图片特效

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS3鼠标经过动画显示图片特效</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #f5f5f5;
            margin: 0;
            font-family: Arial, sans-serif;
            flex-wrap: wrap;
            gap: 30px;
            padding: 20px;
        }
        
        .gallery {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 20px;
            max-width: 1000px;
        }
        
        .image-container {
            position: relative;
            width: 200px;
            height: 200px;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            transition: all 0.5s ease;
        }
        
        .image-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, #ff9a9e, #fad0c4);
            z-index: 1;
            transition: all 0.5s ease;
        }
        
        .image-container:hover::before {
            opacity: 0;
            transform: scale(0.5);
        }
        
        .image-container img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transform: scale(1.2);
            transition: all 0.5s ease;
            filter: grayscale(80%);
        }
        
        .image-container:hover img {
            transform: scale(1);
            filter: grayscale(0%);
        }
        
        .image-title {
            position: absolute;
            bottom: -50px;
            left: 0;
            width: 100%;
            padding: 10px;
            background: rgba(0,0,0,0.7);
            color: white;
            text-align: center;
            transition: all 0.5s ease;
            z-index: 2;
        }
        
        .image-container:hover .image-title {
            bottom: 0;
        }
        
        /* 插入的链接样式 */
        .custom-link {
            position: fixed;
            bottom: 20px;
            right: 20px;
            color: #333;
            text-decoration: none;
            font-size: 14px;
            background: rgba(255,255,255,0.8);
            padding: 8px 15px;
            border-radius: 20px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            transition: all 0.3s ease;
        }
        
        .custom-link:hover {
            background: #fff;
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }
    </style>
</head>
<body>
    <div class="gallery">
        <div class="image-container">
            <img src="https://picsum.photos/id/10/800/800" alt="自然风景">
            <div class="image-title">自然风景</div>
        </div>
        <div class="image-container">
            <img src="https://picsum.photos/id/11/800/800" alt="城市建筑">
            <div class="image-title">城市建筑</div>
        </div>
        <div class="image-container">
            <img src="https://picsum.photos/id/12/800/800" alt="海滩风光">
            <div class="image-title">海滩风光</div>
        </div>
        <div class="image-container">
            <img src="https://picsum.photos/id/13/800/800" alt="山脉景色">
            <div class="image-title">山脉景色</div>
        </div>
        <div class="image-container">
            <img src="https://picsum.photos/id/14/800/800" alt="森林景观">
            <div class="image-title">森林景观</div>
        </div>
        <div class="image-container">
            <img src="https://picsum.photos/id/15/800/800" alt="湖泊风光">
            <div class="image-title">湖泊风光</div>
        </div>
    </div>
    

</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值