演示效果 网址 网址:https://jishiqi-evx.pages.dev/
文件内容 index.html muyu.svg 电子木鱼svg robot.svg 机器人svg script.js style.css
具体代码如下 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 # 计时器项目文件结构 ## index.html ```html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>计时器</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="robot left-robot"> <img src="robot.svg" alt="赛博机器人"> </div> <div class="robot right-robot"> <img src="robot.svg" alt="赛博机器人"> </div> <div class="timer-container"> <h1>计时器</h1> <div class="display">00:00:00</div> <div class="controls"> <button id="startStop">开始</button> <button id="reset">重置</button> </div> </div> <div class="countdown-container"> <h1>倒计时</h1> <div class="countdown-display">00:00:00</div> <div class="countdown-controls"> <div class="time-input"> <input type="number" id="hours" min="0" max="23" placeholder="时"> <span>:</span> <input type="number" id="minutes" min="0" max="59" placeholder="分"> <span>:</span> <input type="number" id="seconds" min="0" max="59" placeholder="秒"> </div> <button id="countdown">开始倒计时</button> <button id="resetCountdown">重置</button> </div> </div> <div class="calendar-container"> <div class="calendar"></div> </div> <div class="wooden-fish"> <img src="muyu.svg" alt="电子木鱼"> <div class="fish-counter">0</div> </div> <script src="script.js"></script> </body> </html>
script.js 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 let timer;let countdownTimer;let isRunning = false ;let isCountdownRunning = false ;let milliseconds = 0 ;let seconds = 0 ;let minutes = 0 ;let hours = 0 ;let countdownHours = 0 ;let countdownMinutes = 0 ;let countdownSeconds = 0 ;
style.css 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 body { font-family : 'Segoe UI' , sans-serif; background : linear-gradient (135deg , #1a1a2e , #16213e ); color : #fff ; display : flex; flex-direction : column; justify-content : center; align-items : center; height : 100vh ; margin : 0 ; gap : 40px ; overflow : hidden; position : relative; } .robot { position : absolute; width : 150px ; height : 150px ; animation : float 8s cubic-bezier (0.36 ,0 ,0.64 ,1 ) infinite; filter : drop-shadow (0 0 10px rgba (0 , 255 , 255 , 0.7 )); z-index : -1 ; } .timer-container , .countdown-container { text-align : center; background : rgba (255 , 255 , 255 , 0.15 ); backdrop-filter : blur (15px ); border-radius : 25px ; padding : 40px ; position : relative; overflow : hidden; border : 2px solid rgba (255 , 255 , 255 , 0.4 ); } button { background : linear-gradient (145deg , #00b4db , #0083b0 ); color : white; border : none; padding : 12px 25px ; border-radius : 50px ; font-size : 1.1rem ; font-weight : 500 ; cursor : pointer; transition : all 0.3s ease; box-shadow : 0 4px 15px rgba (0 , 180 , 219 , 0.4 ); } .wooden-fish { position : fixed; right : 30px ; bottom : 30px ; width : 100px ; height : 100px ; cursor : pointer; filter : drop-shadow (0 0 10px rgba (255 , 255 , 255 , 0.7 )); transition : transform 0.3s ease; }
功能特性
双模式计时:正向计时器 + 可配置倒计时
赛博朋克视觉风格:渐变背景 + 浮动机器人装饰
响应式布局:自适应屏幕尺寸
交互特效:按钮涟漪效果 + 悬浮动画
扩展功能:实时日历 + 电子木鱼彩蛋
使用说明
计时器操作 :
倒计时设置 :
输入时/分/秒数值
开始倒计时后显示剩余时间
可随时暂停或重置
彩蛋功能 :
点击右下角木鱼积累点击次数
带有点击动画效果
实时显示累计点击次数 ```