SVG信封弹出动画特效

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SVG信封弹出动画特效</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #f5f5f5;
            font-family: Arial, sans-serif;
            overflow: hidden;
        }
        
        .container {
            position: relative;
            width: 100%;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        .envelope-wrapper {
            position: relative;
            width: 300px;
            height: 200px;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .envelope-wrapper:hover {
            transform: scale(1.05);
        }
        
        .envelope {
            position: relative;
            width: 100%;
            height: 100%;
        }
        
        .envelope-back {
            position: absolute;
            width: 100%;
            height: 100%;
            background: #4a6ea9;
            border-radius: 5px;
            z-index: 1;
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }
        
        .envelope-front {
            position: absolute;
            width: 100%;
            height: 100%;
            background: #5b7fbb;
            border-radius: 5px;
            z-index: 3;
            transform-origin: bottom;
            transition: all 0.5s ease;
        }
        
        .envelope-wrapper.open .envelope-front {
            transform: rotateX(180deg);
            z-index: 0;
        }
        
        .envelope-top {
            position: absolute;
            width: 0;
            height: 0;
            border-left: 150px solid transparent;
            border-right: 150px solid transparent;
            border-top: 100px solid #3a5a8a;
            top: 0;
            transform-origin: top;
            z-index: 4;
            transition: all 0.5s ease;
        }
        
        .envelope-wrapper.open .envelope-top {
            transform: rotateX(180deg);
            z-index: 2;
        }
        
        .letter {
            position: absolute;
            width: 90%;
            height: 85%;
            background: white;
            border-radius: 3px;
            z-index: 2;
            left: 5%;
            top: 5%;
            transition: all 0.5s ease;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            padding: 10px;
            box-sizing: border-box;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        
        .envelope-wrapper.open .letter {
            transform: translateY(-100px);
            height: 200px;
        }
        
        .letter-content {
            text-align: center;
            color: #333;
        }
        
        .link {
            margin-top: 20px;
            color: #4a6ea9;
            text-decoration: none;
            font-weight: bold;
            transition: color 0.3s;
        }
        
        .link:hover {
            color: #3a5a8a;
        }
        
        h2 {
            color: #4a6ea9;
            margin-bottom: 10px;
        }
        
        p {
            margin: 5px 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="envelope-wrapper">
            <div class="envelope">
                <div class="envelope-back"></div>
                <div class="letter">
                    <div class="letter-content">
                        <h2>您有一封新邮件</h2>
                        <p>点击查看详情内容</p>
                    
                    </div>
                </div>
                <div class="envelope-front"></div>
                <div class="envelope-top"></div>
            </div>
        </div>
    </div>

    <script>
        document.querySelector('.envelope-wrapper').addEventListener('click', function() {
            this.classList.toggle('open');
        });
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值