<!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>