超酷炫!用 HTML 打造独一无二的生日祝福代码
# 酷炫生日祝福HTML代码 以下是一个结合CSS动画和JavaScript的酷炫生日祝福页面代码: ```html <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>生日快乐!</title> <style> body { margin: 0; padding: 0; height: 100vh; display: flex; justify-content: center; align-items: center; background: linear-gradient(45deg, #ff9a9e, #fad0c4, #fbc2eb, #a6c1ee); background-size: 400% 400%; animation: gradientBG 15s ease infinite; font-family: 'Arial', sans-serif; overflow: hidden; } @keyframes gradientBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } .birthday-card { position: relative; width: 80%; max-width: 600px; background: rgba(255, 255, 255, 0.8); border-radius: 20px; padding: 30px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); text-align: center; z-index: 1; transform: scale(0.9); animation: scaleIn 1s forwards; } @keyframes scaleIn { to { transform: scale(1); } } h1 { color: #ff6b6b; font-size: 3rem; margin-bottom: 20px; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); } p { font-size: 1.5rem; color: #555; margin-bottom: 30px; } .balloon { position: absolute; width: 40px; height: 50px; background: #ff6b6b; border-radius: 50%; animation: float 6s ease-in-out infinite; z-index: -1; } .balloon:before { content: ""; position: absolute; width: 2px; height: 100px; background: #ccc; bottom: -100px; left: 50%; transform: translateX(-50%); } @keyframes float { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-100px) rotate(5deg); } } .cake { font-size: 4rem; margin: 20px 0; animation: bounce 1s infinite alternate; } @keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-20px); } } .confetti { position: absolute; width: 10px; height: 10px; background-color: #f00; opacity: 0; } button { background: #ff6b6b; color: white; border: none; padding: 12px 25px; font-size: 1.2rem; border-radius: 50px; cursor: pointer; transition: all 0.3s; box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4); } button:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(255, 107, 107, 0.6); } button:active { transform: translateY(1px); } </style> </head> <body> <div class="birthday-card"> <h1>生日快乐!</h1> <div class="cake">🎂</div> <p>愿你的每一天都充满欢乐和惊喜!</p> <button id="celebrateBtn">点击庆祝!</button> </div> <!-- 气球元素将通过JS动态添加 --> <script> // 创建气球 function createBalloons() { const colors = ['#ff6b6b', '#48dbfb', '#1dd1a1', '#feca57', '#5f27cd']; for (let i = 0; i < 15; i++) { const balloon = document.createElement('div'); balloon.className = 'balloon'; balloon.style.left = Math.random() * 100 + 'vw'; balloon.style.top = Math.random() * 100 + 'vh'; balloon.style.background = colors[Math.floor(Math.random() * colors.length)]; balloon.style.animationDelay = Math.random() * 5 + 's'; balloon.style.transform = `scale(${Math.random() * 0.5 + 0.5})`; document.body.appendChild(balloon); } } // 创建彩色纸屑 function createConfetti() { const colors = ['#ff6b6b', '#48dbfb', '#1dd1a1', '#feca57', '#5f27cd', '#ff9ff3']; const container = document.body; for (let i = 0; i < 100; i++) { const confetti = document.createElement('div'); confetti.className = 'confetti'; confetti.style.left = Math.random() * 100 + 'vw'; confetti.style.top = -10 + 'px'; confetti.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)]; confetti.style.width = Math.random() * 10 + 5 + 'px'; confetti.style.height = Math.random() * 10 + 5 + 'px'; confetti.style.borderRadius = Math.random() > 0.5 ? '50%' : '0'; const animationDuration = Math.random() * 3 + 2; confetti.style.animation = `fall ${animationDuration}s linear forwards`; // 创建下落动画 const keyframes = ` @keyframes fall { to { transform: translateY(100vh) rotate(${Math.random() * 360}deg); opacity: 1; } } `; const style = document.createElement('style'); style.innerHTML = keyframes; document.head.appendChild(style); container.appendChild(confetti); } } // 点击按钮触发庆祝效果 document.getElementById('celebrateBtn').addEventListener('click', function() { createConfetti(); this.textContent = '太棒了!'; this.style.background = '#1dd1a1'; // 添加蛋糕跳动效果 const cake = document.querySelector('.cake'); cake.style.animation = 'bounce 0.5s infinite alternate'; // 3秒后停止跳动 setTimeout(() => { cake.style.animation = ''; }, 3000); }); // 页面加载时创建气球 window.onload = createBalloons; </script> </body> </html> ``` ## 代码特点 1. 渐变动画效果 2. 漂浮的气球装饰元素 3. 点击按钮触发彩色纸屑庆祝效果 4. 蛋糕表情符号跳动动画 5. 卡片缩放进入的入场动画 6. 响应式设计适应不同屏幕尺寸 ## 使用说明 1. 将代码复制到HTML文件中 2. 在浏览器中打开该文件即可看到效果 3. 点击"点击庆祝!"按钮会触发彩色纸屑效果 ## 自定义建议 1. 可以修改文本内容为特定的生日祝福语 2. 调整颜色方案以匹配生日主题 3. 添加音乐或音效增强体验 4. 可以插入实际的照片或图片 ## 注意事项 1. 动画效果可能在某些旧版本浏览器中不完全支持 2. 大量动画元素可能影响性能 3. 移动设备上的触摸事件可能需要额外处理 ######[AI写代码神器 | 1853点数解答 | 2025-06-17 20:23:39]
- C语言实现通讯录按年龄从大到小排序:代码详解与复杂度分析(字节豆包 | 604点数解答 | 2025-12-11 11:24:48)170
- Java 实现学生类:属性封装、静态方法调用与对象信息输出(字节豆包 | 236点数解答 | 2024-09-18 16:15:05)241
- Java JSP 代码:用 List 存储 Map 集合并循环添加姓名和年龄(GPT | 240点数解答 | 2024-11-25 09:17:43)257
- 微信钱包前端演示代码:从问题修正到完善功能及安全提示(字节豆包 | 2097点数解答 | 2025-07-11 18:06:46)162
- 英文打字练习程序:从问题重重到全面优化的蜕变(字节豆包 | 2538点数解答 | 2025-08-20 12:28:06)172
- JavaScript 期末上机大作业:从界面一注册到界面二多元功能的精彩实现! (GPT | 641点数解答 | 2024-12-26 15:17:43)246
- JavaScript 期末上机大作业:从注册界面到多功能布局的挑战与实现 (GPT | 217点数解答 | 2024-12-26 15:17:44)205
- JavaScript 期末上机大作业:从注册界面到多功能界面的挑战之旅(GPT | 314点数解答 | 2024-12-26 15:17:46)217
- JavaScript期末上机大作业:打造注册与多功能界面全攻略!(GPT | 572点数解答 | 2024-12-26 15:17:47)232
- 此需求是代码优化,并非生成标题,以下是优化后的代码,若你需要标题请提供合适的描述信息: ```asp <!-- 包含数据库连接文件 --> <!--#include file="inc/conn.asp"--> <!-- 包含配置文件 --> <!--#include file="inc/config.asp"--> <% ' 声明变量 Dim verifyCode, verifyCode2 ' 初始化错误标志 Dim foundErr foundErr = False ' 检查验证码是否匹配 If Trim(verifyCode) <> Trim(verifyCode2) Then ' 验证码不匹配,输出重定向代码并终止脚本执行 Response.Write "<script language='javascript'>location.href='index.asp'</script>" Response.End foundErr = True Else %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- 设置页面标题 --> <title><%=sitename%></title> <!-- 设置字符编码 --> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> </head> <body> <!-- 页面内容 --> </body> </html> <% End If %> ``` (GPT | 45点数解答 | 2024-07-11 14:16:55)366
- 揭秘:精美 HTML 与 CSS 打造的欢迎网页!(GPT | 324点数解答 | 2024-10-30 19:49:49)293
- HTML5基本文档结构全解析:代码详解与关键逻辑点提醒(DeepSeek | 222点数解答 | 2025-02-18 14:20:46)1864