html+js+css在线倒计时

代码在图片后面  点赞加关注 谢谢大佬照顾😜

图例

时间到前

7f875e47cb434f7887b2ad3b50198269.jpg

 时间到后

d9686c2bdc564b99a94b2092a47b67ae.jpg

 源代码

<!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 {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        background-color: #f4f4f4;
        margin: 0;
        font-family: Arial, sans-serif;
    }
    
    .countdown-container {
        text-align: center;
        border-radius: 8px;
        padding: 20px;
        transition: border-color 0.3s ease;
    }
    
    h1 {
        font-size: 2.5em;
        color: #333;
        margin-bottom: 20px;
      text-align:center;
    }
    
    .time-left {
        font-size: 1.8em;
        color: #333;
        border: 2px solid #4caf50;
        padding: 10px;
        border-radius: 8px;
    }
    
    .time-left.time-up {
        border-color: #e74c3c;
    }
</style>
</head>
<body>
<div class="countdown-container">
    <p class="time-left">距离下班还1分钟</p>
</div>

<script>
    const timeDisplay = document.querySelector('.time-left');
    let countdown = 1 * 60; // 5 minutes in seconds

    function updateCountdown() {
        let minutes = Math.floor(countdown / 60);
        let seconds = countdown % 60;

        minutes = minutes < 10 ? '0' + minutes : minutes;
        seconds = seconds < 10 ? '0' + seconds : seconds;

        timeDisplay.textContent = `距离下班还有${minutes}:${seconds}`;

        if (countdown <= 0) {
            timeDisplay.classList.add('time-up');
            clearInterval(intervalId);
        }

        countdown--;
    }

    const intervalId = setInterval(updateCountdown, 1000);
</script>
</body>
</html>

相关推荐

  1. 如何unity中实现计时

    2024-07-09 23:44:05       37 阅读
  2. 计时80天

    2024-07-09 23:44:05       49 阅读
  3. 计时68天

    2024-07-09 23:44:05       61 阅读
  4. 计时68天

    2024-07-09 23:44:05       67 阅读
  5. 计时67天

    2024-07-09 23:44:05       47 阅读
  6. 计时65天

    2024-07-09 23:44:05       42 阅读
  7. 计时64天

    2024-07-09 23:44:05       52 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 23:44:05       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 23:44:05       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 23:44:05       58 阅读
  4. Python语言-面向对象

    2024-07-09 23:44:05       69 阅读

热门阅读

  1. 把 .py 文件编译成 .pyd 文件

    2024-07-09 23:44:05       23 阅读
  2. 后端工作之一:CrapApi —— API接口管理系统部署

    2024-07-09 23:44:05       20 阅读
  3. C++ 11 智能指针使用详解

    2024-07-09 23:44:05       17 阅读
  4. Perl 数据类型

    2024-07-09 23:44:05       23 阅读
  5. nvm下载

    nvm下载

    2024-07-09 23:44:05      17 阅读
  6. Python中的格式化输出

    2024-07-09 23:44:05       21 阅读
  7. Ubuntu、CentOs更换源(阿里云的源)

    2024-07-09 23:44:05       21 阅读
  8. 华为OD面试分享18

    2024-07-09 23:44:05       20 阅读
  9. 【C++设计模式】(二)设计模式简介

    2024-07-09 23:44:05       22 阅读
  10. 安卓面试题系列--【1】

    2024-07-09 23:44:05       21 阅读
  11. rman 异地恢复某个PDB的步骤

    2024-07-09 23:44:05       18 阅读
  12. 【国产开源可视化引擎Meta2d.js】拖拽

    2024-07-09 23:44:05       19 阅读
  13. 总结:Flink任务执行

    2024-07-09 23:44:05       21 阅读