当前位置: 首页 > news >正文

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>

http://www.lryc.cn/news/392373.html

相关文章:

  • 构建LangChain应用程序的示例代码:55、如何实现多代理模拟,其中特权代理决定谁发言。这遵循与多代理分散发言者选择相反的选择方案
  • 船舶雷达与导航系统选择7/8防水插座的原因分析
  • 墨烯的C语言技术栈-C语言基础-006
  • 常用SHELL命令
  • Python脚本:将Word文档转换为Excel文件
  • 【单链表】03 设L为带头结点的单链表,编写算法实现从尾到头反向输出每个结点的值。
  • 鸿蒙开发设备管理:【@ohos.vibrator (振动)】
  • 【信息学奥赛】CSP-J/S初赛07 排序算法及其他算法在初赛中的考察
  • 第N7周:seq2seq翻译实战-pytorch复现-小白版
  • java集合(1)
  • 分布式数据库HBase:从零开始了解列式存储
  • 接口测试流程及测试点!
  • 已经安装deveco-studio-4.1.3.500的基础上安装deveco-studio-3.1.0.501
  • 【C++】 解决 C++ 语言报错:Use of Uninitialized Variable
  • 2024年7月6日 十二生肖 今日运势
  • ubuntu丢失网络/网卡的一种原因解决方案
  • 第6篇 共识机制深度解析:PoW、PoS、DPoS和PBFT
  • Windows环境使用SpringBoot整合Minio平替OSS
  • LeetCode 196, 73, 105
  • 在Apache HTTP服务器上配置 TLS加密
  • C语言力扣刷题11——打家劫舍1——[线性动态规划]
  • 房屋租赁管理小程序的设计
  • oracle sql语句 排序 fjd = ‘0101‘ 排在 fjd = ‘0103‘ 的前面
  • 初试成绩占比百分之70!计算机专硕均分340+!华中师范大学计算机考研考情分析!
  • 【面向就业的Linux基础】从入门到熟练,探索Linux的秘密(十)-git(2)
  • JMH320【亲测】【御剑九歌】唯美仙侠手游御剑九歌+WIN学习手工端+视频教程+开服清档+运营后台+授权GM物品充值后台
  • 【matlab】信号分解/故障诊断——智能优化算法优化VMD
  • 【重磅】万能模型-直接能换迪丽热巴的模型
  • Web基础和HTTP协议
  • Mini-L-CTF-2022 minispringboot Thymeleaf模板注入 spel的绕过