超炫酷!球球大作战H5启动页加载100%,六大功能按钮音效动画齐上阵!
以下是一个满足你需求的 HTML、CSS 和 JavaScript 代码示例,用于创建一个炫酷的启动页和主页面,适配 iOS 手机的 H5 环境。 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>球球大作战</title> <style> /* 全局样式 */ body { margin: 0; padding: 0; font-family: Arial, sans-serif; overflow: hidden; } /* 启动页样式 */ #splash-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(45deg, #ff00cc, #333399); display: flex; justify-content: center; align-items: center; z-index: 1000; animation: fadeOut 1s ease-in-out 5s forwards; } #loading-bar { width: 300px; height: 20px; background-color: #fff; border-radius: 10px; overflow: hidden; } #loading-progress { width: 0; height: 100%; background: linear-gradient(90deg, #00ff00, #00ffff); border-radius: 10px; animation: loading 5s ease-in-out forwards; } /* 主页面样式 */ #main-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: url('https://source.unsplash.com/random/1920x1080') no-repeat center center fixed; background-size: cover; display: flex; flex-direction: column; justify-content: center; align-items: center; opacity: 0; animation: fadeIn 1s ease-in-out 5s forwards; } h1 { font-size: 48px; color: #fff; text-shadow: 0 0 10px #ff00cc; } .function-buttons { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 20px; } .function-button { width: 100px; height: 100px; border-radius: 50%; background: linear-gradient(45deg, #ff00cc, #333399); margin: 10px; display: flex; justify-content: center; align-items: center; color: #fff; font-size: 18px; cursor: pointer; transition: transform 0.3s ease-in-out; } .function-button:hover { transform: scale(1.1); } /* 动画效果 */ @keyframes loading { 0% { width: 0; } 100% { width: 100%; } } @keyframes fadeOut { 0% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } } @keyframes fadeIn { 0% { opacity: 0; } 100% { opacity: 1; } } </style> </head> <body> <!-- 启动页 --> <div id="splash-screen"> <div id="loading-bar"> <div id="loading-progress"></div> </div> </div> <!-- 主页面 --> <div id="main-screen"> <h1>球球大作战</h1> <div class="function-buttons"> <div class="function-button" onclick="playSoundAndAnimate(this)">功能 1</div> <div class="function-button" onclick="playSoundAndAnimate(this)">功能 2</div> <div class="function-button" onclick="playSoundAndAnimate(this)">功能 3</div> <div class="function-button" onclick="playSoundAndAnimate(this)">功能 4</div> <div class="function-button" onclick="playSoundAndAnimate(this)">功能 5</div> <div class="function-button" onclick="playSoundAndAnimate(this)">功能 6</div> </div> </div> <audio id="click-sound" src="https://www.soundjay.com/button/beep-07.wav"></audio> <script> function playSoundAndAnimate(button) { const sound = document.getElementById('click-sound'); sound.play(); button.style.animation = 'buttonAnimate 0.5s ease-in-out'; button.addEventListener('animationend', () => { button.style.animation = ''; }); } function fadeOutSplash() { const splashScreen = document.getElementById('splash-screen'); splashScreen.style.display = 'none'; } function fadeInMain() { const mainScreen = document.getElementById('main-screen'); mainScreen.style.opacity = 1; } </script> </body> </html> ``` 代码解释 1. 启动页:使用 `#splash-screen` 元素创建启动页,设置了炫酷的渐变。`#loading-bar` 和 `#loading-progress` 用于模拟加载进度条,通过 `animation` 属性实现动态加载效果。 2. 主页面:使用 `#main-screen` 元素创建主页面,设置了动态图片。`h1` 标签显示“球球大作战”,`.function-buttons` 容器包含六个圆形功能按钮。 3. 动画效果:通过 CSS 动画 `loading`、`fadeOut` 和 `fadeIn` 实现加载进度、启动页淡出和主页面淡入效果。 4. 声音效果:使用 `<audio>` 标签添加点击音效,通过 JavaScript 函数 `playSoundAndAnimate` 播放音效并触发按钮动画。 额外注意逻辑点 1. 音频文件路径:代码中使用的音频文件路径是一个示例,实际使用时需要确保音频文件存在并正确引用。 2. 兼容性:虽然代码在大多数现代浏览器和 iOS 设备上可以正常运行,但不同设备的性能和显示效果可能会有所差异,需要进行充分的测试。 3. 响应式设计:为了确保在不同屏幕尺寸的 iOS 设备上都能有良好的显示效果,建议进一步优化 CSS 样式,使用媒体查询等技术实现响应式布局。 ######[AI写代码神器 | 1687点数解答 | 2025-06-15 00:08:41]
- Python 实现简易密码设置系统:多种功能交互与安全要点揭秘(字节豆包 | 286点数解答 | 2025-03-28 10:43:21)361
- C语言实现多功能密码设置系统:含代码及安全注意要点(字节豆包 | 414点数解答 | 2025-03-28 10:43:55)349
- C 语言实现:超简单密码设置系统,含代码与注意要点!(字节豆包 | 519点数解答 | 2025-03-28 12:42:02)387
- C语言实现密码管理系统:含功能代码与安全注意事项(字节豆包 | 409点数解答 | 2025-04-05 18:09:56)333
- C语言实现多功能密码系统:初始化、确认、设置、显示、重置与退出(字节豆包 | 454点数解答 | 2025-04-05 18:48:42)334
- C语言实现密码管理系统:含初始化、确认、设置、显示、重置及退出功能(字节豆包 | 413点数解答 | 2025-04-06 15:37:16)280
- C 语言实现密码管理系统:含初始化、确认、设置、显示、重置及退出功能(字节豆包 | 403点数解答 | 2025-04-06 15:37:54)296
- 补全代码:将数组所有元素赋值为 100 并输出(字节豆包 | 164点数解答 | 2025-11-01 19:14:57)101
- C++实现图像模糊化处理:含代码、解释与复杂度分析(字节豆包 | 670点数解答 | 2025-11-10 18:55:33)111
- C++实现图像像素灰度值模糊化处理:输入输出全解析(字节豆包 | 655点数解答 | 2025-12-01 14:24:01)89
- Python 实现图像模糊化:输入像素值,输出处理后图像(附代码及详细解释)(字节豆包 | 555点数解答 | 2025-12-09 12:22:26)89
- Java JFrame 实现多界面跳转:含登录、注册及个人信息管理功能(讯飞星火 | 503点数解答 | 2024-06-06 23:49:29)395