指针时钟edit icon

创建者:
用户VIUZ4kJ2
Fork(复制)
下载
嵌入
BUG反馈
index.html
style.css
index.js
index.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 {
            background-color: black;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            overflow: hidden;
        }

        .clock {
            width: 300px;
            height: 300px;
            border: 5px solid cyan;
            border-radius: 50%;
            position: relative;
            box-shadow: 0 0 20px cyan;
        }

        .center-dot {
            width: 15px;
            height: 15px;
            background-color: cyan;
            border-radius: 50%;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            box-shadow: 0 0 10px cyan;
        }

        .hand {
            position: absolute;
            bottom: 50%;
            left: 50%;
            transform-origin: bottom center;
            transform: translateX(-50%) rotate(0deg);
            border-radius: 5px;
        }

        .hour-hand {
            width: 6px;
            height: 70px;
            background-color: cyan;
            box-shadow: 0 0 10px cyan;
        }

        .minute-hand {
            width: 4px;
            height: 100px;
            background-color: lime;
            box-shadow: 0 0 10px lime;
        }

        .second-hand {
            width: 2px;
            height: 120px;
            background-color: red;
            box-shadow: 0 0 10px red;
        }

        .clock::before {
            content: "";
            width: 100%;
            height: 100%;
            position: absolute;
            border-radius: 50%;
            background: radial-gradient(circle, rgba(0, 255, 255, 0.1) 30%, black 80%);
            animation: glow 3s infinite alternate;
        }

        @keyframes glow {
            0% { box-shadow: 0 0 10px cyan; }
            100% { box-shadow: 0 0 20px cyan; }
        }
    </style>
</head>
<body>

    <div class="clock">
        <div class="center-dot"></div>
        <div class="hand hour-hand" id="hour"></div>
        <div class="hand minute-hand" id="minute"></div>
        <div class="hand second-hand" id="second"></div>
    </div>

    <script>
        function updateClock() {
            const now = new Date();
            const hours = now.getHours() % 12;
            const minutes = now.getMinutes();
            const seconds = now.getSeconds();

            const hourDeg = (hours * 30) + (minutes * 0.5); 
            const minuteDeg = (minutes * 6) + (seconds * 0.1); 
            const secondDeg = seconds * 6; 

            document.getElementById("hour").style.transform = `translateX(-50%) rotate(${hourDeg}deg)`;
            document.getElementById("minute").style.transform = `translateX(-50%) rotate(${minuteDeg}deg)`;
            document.getElementById("second").style.transform = `translateX(-50%) rotate(${secondDeg}deg)`;
        }

        setInterval(updateClock, 1000);
        updateClock(); 
    </script>

</body>
</html>
        
编辑器加载中
预览
控制台