超简单!用HTML代码打造带动画效果的生日祝福页面
# 生日祝福HTML页面代码 以下是一个简单的生日祝福HTML页面代码,包含基本的样式和动画效果: ```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 { font-family: 'Arial', sans-serif; background-color: #ffebee; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; overflow: hidden; } .card { background-color: white; border-radius: 15px; box-shadow: 0 10px 20px rgba(0,0,0,0.2); padding: 30px; text-align: center; max-width: 500px; position: relative; transform: scale(0.9); animation: scaleUp 0.5s forwards; } h1 { color: #e91e63; margin-bottom: 20px; } p { color: #333; font-size: 18px; line-height: 1.6; } .cake { font-size: 50px; margin: 20px 0; animation: bounce 2s infinite; } .balloon { position: absolute; width: 40px; height: 60px; background-color: #e91e63; border-radius: 50%; opacity: 0.7; } @keyframes scaleUp { to { transform: scale(1); } } @keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } } </style> </head> <body> <div class="card"> <h1>生日快乐!</h1> <div class="cake">🎂</div> <p>愿你的生日充满欢乐和惊喜!</p> <p>祝你心想事成,幸福安康!</p> </div> <script> // 创建气球元素 function createBalloons() { const colors = ['#e91e63', '#2196f3', '#4caf50', '#ffeb3b', '#9c27b0']; for (let i = 0; i < 10; i++) { const balloon = document.createElement('div'); balloon.className = 'balloon'; balloon.style.left = Math.random() * 100 + 'vw'; balloon.style.top = '100vh'; balloon.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)]; balloon.style.transform = `scale(${Math.random() * 0.5 + 0.5})`; document.body.appendChild(balloon); animateBalloon(balloon); } } // 气球动画 function animateBalloon(balloon) { const duration = Math.random() * 5 + 5; const delay = Math.random() * 5; balloon.style.animation = `float ${duration}s linear ${delay}s infinite`; // 添加CSS动画 const style = document.createElement('style'); style.innerHTML = ` @keyframes float { to { top: -100px; opacity: 0; } } `; document.head.appendChild(style); } // 页面加载后创建气球 window.onload = createBalloons; </script> </body> </html> ``` ## 代码说明 1. 这个HTML页面包含一个生日卡片,有动画效果和漂浮的气球 2. 使用了CSS动画使蛋糕图标上下跳动 3. JavaScript动态创建彩色气球并设置动画效果 4. 响应式设计,适合在不同设备上查看 ## 自定义建议 1. 可以修改`<h1>`和`<p>`标签中的文字内容为个性化祝福语 2. 调整CSS中的颜色值来改变整体配色方案 3. 添加更多装饰元素或图片使页面更加丰富 ## 注意事项 1. 气球动画使用了动态创建的CSS关键帧,这可能会影响性能 2. 气球元素创建后没有清理机制,长时间运行可能导致内存增加 3. 动画效果在某些旧版本浏览器上可能不兼容 ######[AI写代码神器 | 1000点数解答 | 2025-06-17 20:25:48]
- C语言实现通讯录按年龄从大到小排序:代码详解与复杂度分析(字节豆包 | 604点数解答 | 2025-12-11 11:24:48)170
- Java 实现学生类:属性封装、静态方法调用与对象信息输出(字节豆包 | 236点数解答 | 2024-09-18 16:15:05)241
- Android开发必备:多种动画API解析及使用注意事项(阿里通义 | 355点数解答 | 2023-11-07 22:46:27)240
- 2 秒动画搞定!“好句子”如何稳停结束位置( | 456点数解答 | 2024-05-19 16:46:15)280
- 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