Bootstrap

【Node.js】时钟案例(20220907)

一、时钟页面实现准备

  • 时钟效果图
    20220906(1)

HTML+CSS+JS代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>时钟首页</title>
    <style>
        .box {
     
            width: 400px;
            height: 250px;
            border: 5px solid black;
            margin: 100px auto;
            line-height: 250px;
            text-align: center;
            font-size: 70px;
            font-weight: 700;
            background-color: pink;
        }
    </style>
</head>

<body>
    <div class="box"></div>

    <script>
        setInterval(function () {
     
            function getTimer() {
     
                var time = new Date();
                var h = time.getHours();
                h = h < 10 ? '0' + h : h
;