<!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>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
background: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.success-container {
text-align: center;
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
max-width: 400px;
width: 90%;
position: relative;
overflow: hidden;
}
.checkmark-circle {
width: 100px;
height: 100px;
border-radius: 50%;
background: #4CAF50;
margin: 0 auto 25px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
animation: circle-fill 0.6s ease-in-out;
}
.checkmark {
width: 50px;
height: 50px;
}
.checkmark-stem {
position: absolute;
width: 12px;
height: 25px;
background-color: white;
left: 50px;
top: 45px;
transform: rotate(45deg);
transform-origin: left bottom;
animation: stem-draw 0.5s ease-out 0.6s both;
}
.checkmark-kick {
position: absolute;
width: 12px;
height: 50px;
background-color: white;
left: 35px;
top: 45px;
transform: rotate(-45deg);
transform-origin: left bottom;
animation: kick-draw 0.4s ease-out 1.1s both;
}
h1 {
color: #333;
margin-bottom: 15px;
font-size: 24px;
animation: fadeIn 0.5s ease-out 1.5s both;
}
p {
color: #666;
margin-bottom: 25px;
line-height: 1.6;
animation: fadeIn 0.5s ease-out 1.7s both;
}
.order-info {
background: #f9f9f9;
padding: 15px;
border-radius: 5px;
margin-bottom: 25px;
text-align: left;
animation: fadeIn 0.5s ease-out 1.9s both;
}
.order-info p {
margin-bottom: 8px;
color: #555;
animation: none;
}
.btn {
display: inline-block;
padding: 12px 30px;
background: #4CAF50;
color: white;
text-decoration: none;
border-radius: 5px;
font-weight: bold;
transition: all 0.3s;
animation: fadeIn 0.5s ease-out 2.1s both;
}
.btn:hover {
background: #45a049;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.link {
display: block;
margin-top: 30px;
color: #666;
font-size: 14px;
text-decoration: none;
animation: fadeIn 0.5s ease-out 2.3s both;
}
.link:hover {
color: #4CAF50;
}
/* 动画效果 */
@keyframes circle-fill {
0% {
transform: scale(0);
opacity: 0;
}
50% {
transform: scale(1.1);
opacity: 1;
}
100% {
transform: scale(1);
}
}
@keyframes stem-draw {
0% {
height: 0;
}
100% {
height: 25px;
}
}
@keyframes kick-draw {
0% {
height: 0;
}
100% {
height: 50px;
}
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* 装饰元素 */
.confetti {
position: absolute;
width: 10px;
height: 10px;
background: #4CAF50;
opacity: 0;
}
@keyframes confetti-fall {
0% {
transform: translateY(-100px) rotate(0deg);
opacity: 1;
}
100% {
transform: translateY(100px) rotate(360deg);
opacity: 0;
}
}
</style>
</head>
<body>
<div class="success-container">
<div class="checkmark-circle">
<div class="checkmark">
<div class="checkmark-stem"></div>
<div class="checkmark-kick"></div>
</div>
</div>
<h1>支付成功!</h1>
<p>您的订单已支付成功,我们将尽快为您处理</p>
<div class="order-info">
<p><strong>订单编号:</strong>TB20230615001</p>
<p><strong>支付金额:</strong>¥128.00</p>
<p><strong>支付时间:</strong>2023-06-15 14:30:25</p>
</div>
<a href="#" class="btn">查看订单详情</a>
</div>
<script>
// 创建彩色纸屑效果
function createConfetti() {
const colors = ['#4CAF50', '#8BC34A', '#CDDC39', '#FFEB3B', '#FFC107', '#FF9800'];
const container = document.querySelector('.success-container');
for (let i = 0; i < 30; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.background = colors[Math.floor(Math.random() * colors.length)];
confetti.style.left = Math.random() * 100 + '%';
confetti.style.top = '-10px';
confetti.style.animation = `confetti-fall ${Math.random() * 2 + 1}s ease-in ${Math.random() * 0.5}s forwards`;
container.appendChild(confetti);
// 动画结束后移除元素
setTimeout(() => {
confetti.remove();
}, 3000);
}
}
// 页面加载后触发彩色纸屑效果
window.addEventListener('load', () => {
setTimeout(createConfetti, 1500);
});
</script>
</body>
</html>