超甜!用 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 { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #ACDEFF; font-family: 'Arial', sans-serif; text-align: center; transition: background-color 0.5s; } .container { background-color: #F9FFFF; padding: 30px; border-radius: 15px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); max-width: 80%; } h1 { color: #e91e63; margin-bottom: 30px; } .image-container { margin-bottom: 20px; height: 200px; display: flex; justify-content: center; align-items: center; } .image-container img { max-height: 100%; max-width: 100%; display: none; } .image-container img.active { display: block; } .buttons { display: flex; justify-content: center; gap: 20px; } #yesBtn { background-color: #4caf50; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 16px; transition: all 0.3s; } #noBtn { background-color: #f44336; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 16px; transition: all 0.3s; } #yesBtn:hover, #noBtn:hover { opacity: 0.8; } </style> </head> <body> <div class="container"> <h1>可以成为千一的恋人吗?</h1> <div class="image-container"> <img src="https://s3.bmp.ovh/imgs/2025/07/26/1d40e20226747686.jpg" class="active" alt="可以成为千一的恋人吗"> <img src="https://s3.bmp.ovh/imgs/2025/07/26/5422e5281214f40c.jpg" alt="真的不可以嘛?"> <img src="https://s3.bmp.ovh/imgs/2025/07/26/132a2d971d0b9a5b.jpg" alt="不要嘛,再想一想"> <img src="https://s3.bmp.ovh/imgs/2025/07/26/77ed0e5e589807fb.jpg" alt="不行,你必须当千一的恋人"> <img src="https://s3.bmp.ovh/imgs/2025/07/26/215a4d774c7d26ef.jpg" alt="千一真的真的超爱你的"> </div> <div class="buttons"> <button id="yesBtn">可以</button> <button id="noBtn">不要</button> </div> </div> <script> const yesBtn = document.getElementById('yesBtn'); const noBtn = document.getElementById('noBtn'); const images = document.querySelectorAll('.image-container img'); const body = document.querySelector('body'); const bgColors = ['#ACDEFF', '#D1EEED', '#DBF3FE', '#F9FFFF', '#E0F7FA']; let fontSize = 16; let clickCount = 0; noBtn.addEventListener('click', function() { clickCount++; fontSize += 8; yesBtn.style.fontSize = `${fontSize}px`; yesBtn.style.padding = `${fontSize/2}px ${fontSize}px`; const maxX = window.innerWidth - noBtn.offsetWidth - 50; const maxY = window.innerHeight - noBtn.offsetHeight - 50; const randomX = Math.max(0, Math.floor(Math.random() * maxX)); const randomY = Math.max(0, Math.floor(Math.random() * maxY)); noBtn.style.position = 'absolute'; noBtn.style.left = `${randomX}px`; noBtn.style.top = `${randomY}px`; images.forEach(img => img.classList.remove('active')); const imgIndex = Math.min(clickCount, images.length - 1); images[imgIndex].classList.add('active'); body.style.backgroundColor = bgColors[imgIndex % bgColors.length]; }); yesBtn.addEventListener('click', function() { alert('千一真的真的超爱你的!٩(๛ ˘ ³˘)۶♥'); images.forEach(img => img.classList.remove('active')); images[images.length - 1].classList.add('active'); body.style.backgroundColor = bgColors[bgColors.length - 1]; }); </script> </body> </html> ``` ## 功能说明 1. 页面加载时显示第一张图片和问题 2. 每次点击"不要"按钮时: - "可以"按钮尺寸增大 - "不要"按钮随机移动 - 切换到下一张图片 - 颜色循环变化 3. 点击"可以"按钮时: - 显示确认消息 - 切换到最后的爱心图片 - 变为最后的颜色 ## 使用说明 1. 复制全部代码 2. 保存为HTML文件(如`qianyi_love.html`) 3. 双击文件在浏览器中打开 4. 尝试点击"不要"按钮观察效果 ## 注意事项 1. 图片需要网络连接才能加载 2. 按钮增长有上限(受限于屏幕尺寸) 3. 移动端可能需要调整图片容器高度 4. 颜色循环使用您提供的配色方案 ######[AI写代码神器 | 1411点数解答 | 2025-07-26 08:37:17]
- Java JSP 代码:用 List 存储 Map 集合并循环添加姓名和年龄(GPT | 240点数解答 | 2024-11-25 09:17:43)241
- 微信钱包前端演示代码:从问题修正到完善功能及安全提示(字节豆包 | 2097点数解答 | 2025-07-11 18:06:46)147
- 英文打字练习程序:从问题重重到全面优化的蜕变(字节豆包 | 2538点数解答 | 2025-08-20 12:28:06)158
- 此需求是代码优化,并非生成标题,以下是优化后的代码,若你需要标题请提供合适的描述信息: ```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)351
- 揭秘:精美 HTML 与 CSS 打造的欢迎网页!(GPT | 324点数解答 | 2024-10-30 19:49:49)283
- HTML5基本文档结构全解析:代码详解与关键逻辑点提醒(DeepSeek | 222点数解答 | 2025-02-18 14:20:46)1849
- 网页代码小优化:给男友爱的消息提示框升级秘籍 (字节豆包 | 139点数解答 | 2025-03-17 22:07:34)242
- 生日祝福 HTML 代码优化建议与逻辑要点大揭秘(字节豆包 | 164点数解答 | 2025-03-19 22:07:03)219
- 揭秘贷款额度图片生成器:代码剖析与潜在问题 (DeepSeek | 195点数解答 | 2025-04-10 15:45:03)223
- 贷款额度图片生成器:从简单实现到功能升级全解析 (DeepSeek | 725点数解答 | 2025-04-10 15:46:20)155
- HTML 心跳动画代码优化指南:让你的网页“心动”升级!(字节豆包 | 136点数解答 | 2025-05-24 10:49:09)145
- 奥特曼特摄站代码:从问题重重到完美优化全揭秘(字节豆包 | 1523点数解答 | 2025-06-04 13:19:47)621